Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wisdom-components
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
wisdom-components
Commits
fbdaf482
Commit
fbdaf482
authored
Feb 07, 2023
by
崔佳豪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(EC_HistoryView): 优化网格开关显示
parent
2d00b49e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
30 deletions
+35
-30
SingleChart.js
packages/extend-components/EC_HistoryView/src/SingleChart.js
+34
-29
index.js
packages/extend-components/EC_HistoryView/src/index.js
+1
-1
No files found.
packages/extend-components/EC_HistoryView/src/SingleChart.js
View file @
fbdaf482
...
...
@@ -2,6 +2,7 @@ import React, { memo, useEffect, useMemo, useRef } from 'react';
import
{
BasicChart
}
from
'@wisdom-components/basicchart'
;
import
PandaEmpty
from
'@wisdom-components/empty'
;
import
optionGenerator
from
'./utils'
;
import
{
isArray
,
cloneDeep
}
from
'lodash'
;
const
SimgleChart
=
memo
((
props
)
=>
{
const
{
...
...
@@ -21,41 +22,45 @@ const SimgleChart = memo((props) => {
showGridLine
,
};
return
optionGenerator
(
dataSource
,
null
,
contrast
,
contrastOption
,
smooth
,
config
);
},
[
dataSource
,
smooth
,
curveCenter
,
showGridLine
]);
},
[
dataSource
,
smooth
,
curveCenter
]);
useEffect
(()
=>
{
chartRef
.
current
?.
resize
?.();
const
chart
=
chartRef
.
current
.
getEchartsInstance
(
);
},
[]
);
function
hander
(
params
)
{
const
{
selected
}
=
params
;
const
count
=
Object
.
values
(
selected
||
{}).
filter
((
item
)
=>
item
).
length
;
if
(
count
===
1
)
{
chart
.
setOption
({
tooltip
:
{
trigger
:
'axis'
,
axisPointer
:
{
type
:
'cross'
,
},
},
});
}
else
{
chart
.
setOption
({
tooltip
:
{
trigger
:
'axis'
,
axisPointer
:
{
type
:
'line'
,
},
},
});
}
}
// 网格开关,不更新整个图表
useEffect
(()
=>
{
const
chart
=
chartRef
.
current
.
getEchartsInstance
();
if
(
!
chart
)
return
;
chart
.
on
(
'legendselectchanged'
,
hander
);
return
()
=>
{
chart
.
off
(
'legendselectchanged'
,
hander
);
const
option
=
chart
.
getOption
();
// 交互指针
const
tooltip
=
{
trigger
:
'axis'
,
axisPointer
:
{
type
:
showGridLine
?
'cross'
:
'line'
,
},
};
},
[]);
// 网格线
const
axisConfig
=
{
minorTick
:
{
show
:
showGridLine
,
},
minorSplitLine
:
{
show
:
showGridLine
,
},
splitLine
:
{
show
:
showGridLine
,
},
};
let
yAxis
=
axisConfig
;
if
(
isArray
(
option
.
yAxis
))
{
yAxis
=
option
.
yAxis
.
map
((
item
)
=>
({
...
axisConfig
}));
}
chart
.
setOption
({
yAxis
,
tooltip
,
});
},
[
showGridLine
]);
// 数据都为空显示缺省页
const
isEmpty
=
useMemo
(
...
...
packages/extend-components/EC_HistoryView/src/index.js
View file @
fbdaf482
...
...
@@ -215,7 +215,7 @@ const HistoryView = (props) => {
const
[
contrastOption
,
setContrastOption
]
=
useState
(
'day'
);
// 对比时间类型: 日/月
const
[
datePickerArr
,
setDatePickerArr
]
=
useState
(
DefaultDatePicker
(
'day'
));
// 对比时间段配置值
const
[
checkboxData
,
setCheckboxData
]
=
useState
(
CheckboxData
);
// 曲线设置项
const
[
checkboxData
,
setCheckboxData
]
=
useState
(
()
=>
[...
CheckboxData
]
);
// 曲线设置项
const
[
dataThinKey
,
setDataThinKey
]
=
useState
(
timeIntervalList
[
0
].
key
);
// 曲线抽稀时间设置
const
[
columns
,
setColumns
]
=
useState
([]);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment