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
2beb13a6
Commit
2beb13a6
authored
May 11, 2023
by
陈龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 优化图表代码
parent
0c33a949
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
11 deletions
+25
-11
utils.js
packages/extend-components/EC_HistoryView/src/utils.js
+25
-11
No files found.
packages/extend-components/EC_HistoryView/src/utils.js
View file @
2beb13a6
...
@@ -319,6 +319,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
...
@@ -319,6 +319,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
top
:
needUnit
?
80
:
60
,
top
:
needUnit
?
80
:
60
,
left
:
10
+
leftNum
*
axisWidth
,
left
:
10
+
leftNum
*
axisWidth
,
right
:
rightNum
===
0
?
20
:
rightNum
*
axisWidth
,
right
:
rightNum
===
0
?
20
:
rightNum
*
axisWidth
,
bottom
:
60
};
};
const
headTemplate
=
(
param
)
=>
{
const
headTemplate
=
(
param
)
=>
{
if
(
!
param
)
return
''
;
if
(
!
param
)
return
''
;
...
@@ -465,18 +466,19 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
...
@@ -465,18 +466,19 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
if (!justLine && chartType) {
if (!justLine && chartType) {
if (chartType === 'boxChart') {
if (chartType === 'boxChart') {
const otherData = dataSource?.[0]?.dataModel.map(item => {
const otherData = dataSource?.[0]?.dataModel.map(item => {
const {firstPV, lastPV, maxPV, minPV} = item;
const {firstPV, lastPV, maxPV, minPV
, pt
} = item;
return [firstPV, lastPV, minPV, maxPV]
return [
moment(pt).valueOf(),
firstPV, lastPV, minPV, maxPV]
}) || []; //当存在othersData的时候,只是单曲线
}) || []; //当存在othersData的时候,只是单曲线
xAxis = {type: 'category', data: series[0].data.map(item => moment(item[0]).format('YYYY-MM-DD HH:mm:ss'))};
// xAxis = {type: 'category', data: series[0].data.map(item => moment(item[0]).format('YYYY-MM-DD HH:mm:ss'))};
xAxis = {type: 'time'};
decorateAxisGridLine(xAxis, showGridLine);
decorateAxisGridLine(xAxis, showGridLine);
let unit = ''
let unit = ''
series = series.map(item => {
series = series.map(item => {
if (item.unit) unit = item.unit;
if (item.unit) unit = item.unit;
let _item = {...item, symbol: 'none'};
let _item = {...item, symbol: 'none'};
_item.data = _item?.data?.map(d => {
/*
_item.data = _item?.data?.map(d => {
return d[1] || null
return d[1] || null
}) || [];
}) || [];*/
return _item;
return _item;
})
})
series.push({
series.push({
...
@@ -495,18 +497,21 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
...
@@ -495,18 +497,21 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
} else {
} else {
let _maxData = [];
let _maxData = [];
let _minData = [];
let _minData = [];
const formatStr = contrastOption === 'day' ? '2020-01-01 HH:mm:00' : '2020-01-DD HH:mm:00';// 用来做同期对比,把日期拉到同一区间
dataSource?.[0]?.dataModel.forEach(item => {
dataSource?.[0]?.dataModel.forEach(item => {
const {firstPV, lastPV, maxPV, minPV} = item;
const {firstPV, lastPV, maxPV, minPV, pt} = item;
_maxData.push(maxPV);
let time = contrast ? moment(pt).format(formatStr) : pt;
_minData.push(minPV);
_maxData.push([moment(time).valueOf(), maxPV - minPV]);
_minData.push([moment(time).valueOf(), minPV]);
}); //当存在othersData的时候,只是单曲线
}); //当存在othersData的时候,只是单曲线
xAxis = {type: 'category', data: series[0].data.map(item => moment(item[0]).format('YYYY-MM-DD HH:mm:ss'))};
// xAxis = {type: 'category', data: series[0].data.map(item => moment(item[0]).format('YYYY-MM-DD HH:mm:ss'))};
xAxis = {type: 'time'};
decorateAxisGridLine(xAxis, showGridLine);
decorateAxisGridLine(xAxis, showGridLine);
series = series.map(item => {
series = series.map(item => {
let _item = {...item, symbol: 'none'};
let _item = {...item, symbol: 'none'};
_item.data = _item?.data?.map(d => {
/*
_item.data = _item?.data?.map(d => {
return d[1] || null
return d[1] || null
}) || [];
}) || [];*/
return _item;
return _item;
});
});
console.log(series);
console.log(series);
...
@@ -530,6 +535,15 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
...
@@ -530,6 +535,15 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
})
})
}
}
}
}
restOption.dataZoom = [
{
show: true,
bottom: 10,
start: 0,
end: 100,
height: 28
}
];
return {
return {
yAxis,
yAxis,
grid,
grid,
...
...
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