Commit 00852529 authored by 张瑶's avatar 张瑶

fix: 更新

parent da8c57a7
import React, { memo, useEffect, useMemo, useRef } from 'react';
import { BasicChart } from '@wisdom-components/basicchart';
import PandaEmpty from '@wisdom-components/empty';
import optionGenerator, { alarmMarkLine, minMaxMarkPoint } from './utils';
import optionGenerator, { alarmMarkLine, minMaxMarkPoint, offlineArea } from './utils';
import { isArray, cloneDeep } from 'lodash';
const SimgleChart = memo((props) => {
......@@ -46,11 +46,14 @@ 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;
......
......@@ -192,6 +192,46 @@ 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 = [];
let hasOffline = false;
dataModel.forEach((item) => {
if (!item.pv && !hasOffline) {
offlineData = [
{
name: '离线',
xAxis: item.pt,
},
];
hasOffline = true;
} else if (item.pv && hasOffline) {
offlineData.push({
xAxis: item.pt,
});
datas.push(offlineData);
offlineData = [];
hasOffline = false;
}
});
console.log('wwww', datas);
return {
itemStyle: {
color: '#eee',
},
data: datas,
};
};
/**
* 图表配置项生成
*
......
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