Commit 813ac070 authored by 崔佳豪's avatar 崔佳豪

fix(EC_HistoryView): 添加最值标记

parent 7a7438d1
import React, { memo, useEffect, useMemo, useRef } from 'react'; import React, { memo, useEffect, useMemo, useRef } from 'react';
import { BasicChart } from '@wisdom-components/basicchart'; import { BasicChart } from '@wisdom-components/basicchart';
import PandaEmpty from '@wisdom-components/empty'; import PandaEmpty from '@wisdom-components/empty';
import optionGenerator, { alarmMarkLine } from './utils'; import optionGenerator, { alarmMarkLine, minMaxMarkPoint } from './utils';
import { isArray, cloneDeep } from 'lodash'; import { isArray, cloneDeep } from 'lodash';
const SimgleChart = memo((props) => { const SimgleChart = memo((props) => {
...@@ -36,10 +36,18 @@ const SimgleChart = memo((props) => { ...@@ -36,10 +36,18 @@ const SimgleChart = memo((props) => {
const option = cloneDeep(chart.getOption()); const option = cloneDeep(chart.getOption());
const needMarkLine = count === 1; const needMarkLine = count === 1;
option.series.forEach((item, index) => { option.series.forEach((item, index) => {
item.markLine = if (needMarkLine && selected[item.name]) {
needMarkLine && selected[item.name] item.markLine = alarmMarkLine(
? alarmMarkLine(dataSource[index], index, [dataSource[index]], deviceAlarmSchemes) dataSource[index],
: {}; index,
[dataSource[index]],
deviceAlarmSchemes,
);
item.markPoint = minMaxMarkPoint(dataSource[index], index, [dataSource[index]]);
} else {
item.markLine = {};
item.markPoint = {};
}
}); });
chart.setOption(option, true); chart.setOption(option, true);
} }
......
...@@ -103,11 +103,6 @@ export const alarmMarkLine = (dataItem, index, dataSource, schemes) => { ...@@ -103,11 +103,6 @@ export const alarmMarkLine = (dataItem, index, dataSource, schemes) => {
llLimit !== null && llLimit !== void 0 && data.push(markLineItem('低低限', llLimit, '#FF0000')); llLimit !== null && llLimit !== void 0 && data.push(markLineItem('低低限', llLimit, '#FF0000'));
hhLimit !== null && hhLimit !== void 0 && data.push(markLineItem('高高限', hhLimit, '#FF0000')); hhLimit !== null && hhLimit !== void 0 && data.push(markLineItem('高高限', hhLimit, '#FF0000'));
}); });
// 添加均值线
const sum = (dataItem.dataModel || []).reduce(
(pre, item) => (isNaN(Number(item.pv)) ? pre : item.pv),
0,
);
data.push({ data.push({
name: '平均线', name: '平均线',
type: 'average', type: 'average',
...@@ -129,6 +124,18 @@ export const alarmMarkLine = (dataItem, index, dataSource, schemes) => { ...@@ -129,6 +124,18 @@ export const alarmMarkLine = (dataItem, index, dataSource, schemes) => {
}; };
}; };
export const minMaxMarkPoint = (dataItem, index, dataSource) => {
// 只有一个数据曲线时显示markline
if (!dataItem || dataSource.length !== 1) return {};
const data = [];
data.push({ type: 'min', name: '最小值', label: { color: '#FFFFFF' } });
data.push({ type: 'max', name: '最大值', label: { color: '#FFFFFF' } });
return {
symbol: 'pin',
data,
};
};
/** /**
* 坐标轴添加网格线配置 * 坐标轴添加网格线配置
* *
...@@ -258,6 +265,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth ...@@ -258,6 +265,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
const areaStyle = areaStyleFormatter(item); const areaStyle = areaStyleFormatter(item);
const yAxisIndex = yAxisInterator.get(sensorName); const yAxisIndex = yAxisInterator.get(sensorName);
const markLine = alarmMarkLine(item, index, dataSource, deviceAlarmSchemes); const markLine = alarmMarkLine(item, index, dataSource, deviceAlarmSchemes);
const markPoint = minMaxMarkPoint(item, index, dataSource);
return { return {
notMerge: true, notMerge: true,
name, name,
...@@ -268,6 +276,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth ...@@ -268,6 +276,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
smooth, smooth,
unit, unit,
markLine, markLine,
markPoint,
}; };
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment