Commit 0a460799 authored by 陈龙's avatar 陈龙

fix: 修复数据返回异常导致的报错

parent bb934b53
......@@ -9,7 +9,7 @@ const deviceParams = [
// deviceType: '二供泵房',
// pointAddressID: 4,
// },
{
/* {
// deviceCode: 'EGBF00000002',
// deviceCode: 'EGBF00000018',
deviceCode: 'XMYL00000345',
......@@ -19,13 +19,18 @@ const deviceParams = [
sensors: '进水压力',
deviceType: '熊猫压力表',
pointAddressID: 4,
},
},*/
// {
// deviceCode: 'EGJZ00001113',
// sensors: '出水压力',
// deviceType: '二供机组',
// pointAddressID: 4,
// },
{
"deviceCode": "EGJZ00000163",
"sensors": "进水压力,是否在线",
"deviceType": "二供机组"
}
];
const Demo = () => {
return (
......
......@@ -739,6 +739,7 @@ const HistoryView = (props) => {
setLoading(true);
Promise.all(requestArr).then((results) => {
if (results.length) {
debugger
let data = [];
results.forEach((res, index) => {
const {dateFrom, dateTo} = dateRange?.[index] ?? {};
......@@ -761,7 +762,7 @@ const HistoryView = (props) => {
} else {
return {};
}
});
}).filter(item => item.sensorName);
data = data.concat(list);
});
}
......
......@@ -281,6 +281,29 @@ export const offlineArea = (dataItem) => {
data: datas,
};
};
export const buildDefaultLegend = (option) => {
const {title} = option;
let paddingRight = 0;
if (title && title.show) paddingRight = 80; // 给标题留够空间
return {
show: true,
right: 20,
top: 20,
icon: 'rect',
itemWidth: 14,
itemHeight: 8,
itemGap: 20,
padding: [0, 0, 0, paddingRight],
textStyle: {
padding: [0, 0, 0, 4],
color: '#2d2d2d',
},
};
};
const headTemplate = (param) => {
if (!param) return '';
const {name, axisValueLabel, axisType, axisValue} = param;
......@@ -540,16 +563,7 @@ const assignOptions = (restOption, xAxis, legendData) => {
];
xAxis.minInterval = 3600 * (1 * 1000);
if (legendData) {
restOption.legend = {
// orient: 'vertical',
data: legendData,
itemGap: 10,
padding: [0, 0, 0, 200],
textStyle: {
width: 120,
overflow: 'truncate',
},
}
restOption.legend = {...buildDefaultLegend({}), ...{data: legendData}};
}
};
/**
......@@ -615,6 +629,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
let unit = '';
series = series.map((item) => {
if (item.unit) unit = item.unit;
item.areaStyle = null;
return {...item, symbol: 'none'};
});
series.push({
......@@ -653,6 +668,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
let _unit = '';
series = series.map((item) => {
_unit = item.unit;
item.areaStyle = null;
return {...item, symbol: 'none'};
});
[[..._minData], [..._maxData]].forEach((item, index) => {
......
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