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

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

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