Commit 5df25a71 authored by 张瑶's avatar 张瑶

fix: 历史数据曲线更新

parent e3be0a7d
......@@ -38,6 +38,11 @@ const SimgleChart = memo((props) => {
const option = cloneDeep(chart.getOption());
const needMarkLine = count === 1;
option.series.forEach((item, index) => {
let offlineAreas = offlineArea(dataSource[index]);
if (offlineAreas.data?.length) {
option.markArea = null;
item.markArea = offlineAreas;
}
if (needMarkLine && selected[item.name]) {
item.markLine = alarmMarkLine(
dataSource[index],
......@@ -46,14 +51,11 @@ const SimgleChart = memo((props) => {
deviceAlarmSchemes,
);
item.markPoint = minMaxMarkPoint(dataSource[index], index, [dataSource[index]]);
item.markArea = offlineArea(dataSource[index]);
} else {
item.markLine = {};
item.markPoint = {};
item.markArea = offlineArea(dataSource[index]);
}
});
console.log('wwww', option);
chart.setOption(option, true);
}
if (!chart) return;
......
......@@ -198,9 +198,7 @@ export const decorateAxisGridLine = (axis, showGrid) => {
* @param {any} dataItem
*/
export const offlineArea = (dataItem) => {
// 只有一个数据曲线时显示markline
if (!dataItem) return {};
console.log('wwww', dataItem);
const { dataModel } = dataItem;
let datas = new Array();
let offlineData = [];
......@@ -210,20 +208,19 @@ export const offlineArea = (dataItem) => {
offlineData = [
{
name: '离线',
xAxis: item.pt,
xAxis: new Date(item.pt),
},
];
hasOffline = true;
} else if (item.pv && hasOffline) {
offlineData.push({
xAxis: item.pt,
xAxis: new Date(item.pt),
});
datas.push(offlineData);
offlineData = [];
hasOffline = false;
}
});
console.log('wwww', datas);
return {
itemStyle: {
color: '#eee',
......@@ -331,6 +328,12 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
const yAxisIndex = yAxisInterator.get(sensorName);
const markLine = showMarkLine ? alarmMarkLine(item, index, dataSource, deviceAlarmSchemes) : {};
const markPoint = showPoint ? minMaxMarkPoint(item, index, dataSource) : {};
let markArea = null;
let offlineAreas = offlineArea(item);
if (offlineAreas.data?.length) {
restOption.markArea = null;
markArea = offlineAreas;
}
return {
notMerge: true,
name,
......@@ -342,6 +345,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
unit,
markLine,
markPoint,
markArea,
};
});
......
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