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

fix: 历史数据曲线更新

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