Commit 34a7dba7 authored by 陈龙's avatar 陈龙

fix: 修复单位问题

parent c2e87df9
......@@ -22,15 +22,15 @@ path: /
## 单图表
<code src="./demos/index.js">
<code src="./demos/index.js"></code>
## 移动端
<code src="./demos/mobile.js">
<code src="./demos/mobile.js"></code>
## 多图表
[//]: # (<code src="./demos/GridDemo.js">)
<code src="./demos/GridDemo.js"></code>
## API
......
import React from 'react';
import HistoryView from '../index';
const deviceParams = [
/*const deviceParams = [
{
deviceCode: 'EGBF00000146',
sensors: '进水压力,出水瞬时流量,出水累计流量',
......@@ -21,9 +21,23 @@ const deviceParams = [
deviceType: '二供泵房',
pointAddressID: 4,
},
];
];*/
const deviceParams = [
{
"deviceCode": "LLJ00000055",
"sensors": "瞬时流量,正累计流量,是否在线",
"deviceType": "流量计"
},
{
"deviceCode": "LLJ00000056",
"sensors": "瞬时流量,正累计流量,是否在线",
"deviceType": "流量计"
}
]
const Demo = () => {
return <div style={{ height: 700 }}>{/*<HistoryView deviceParams={deviceParams} grid />*/}</div>;
return <div style={{ height: 700 }}>
<HistoryView deviceParams={deviceParams} grid />
</div>;
};
export default Demo;
......@@ -3,34 +3,39 @@ import HistoryView from '../index';
import {MobileHistoryChart} from "../mobile";
const deviceParams = [
// {
// deviceCode: 'EGBF00000146',
// sensors: '进水压力,出水瞬时流量,出水累计流量',
// deviceType: '二供泵房',
// pointAddressID: 4,
// },
/* {
// deviceCode: 'EGBF00000002',
// deviceCode: 'EGBF00000018',
deviceCode: 'XMYL00000345',
// deviceCode: 'XMYL00000000',
// deviceCode: 'EGBF00000014',
// sensors: '今日供水量,今日用电量,1#水箱液位,是否在线',
sensors: '进水压力',
deviceType: '熊猫压力表',
pointAddressID: 4,
},*/
// {
// deviceCode: 'EGJZ00001113',
// sensors: '出水压力',
// deviceType: '二供机组',
// pointAddressID: 4,
// },
/* {
deviceCode: 'EGBF00000141',
sensors: '进水压力,出水瞬时流量,出水累计流量',
deviceType: '二供泵房',
pointAddressID: 208,
},*/
/* {
// deviceCode: 'EGBF00000002',
// deviceCode: 'EGBF00000018',
// deviceCode: 'XMYL00000345',
// deviceCode: 'XMYL00000000',
deviceCode: 'EGBF00000014',
// sensors: '今日供水量,今日用电量,1#水箱液位,是否在线',
sensors: '进水压力',
deviceType: '熊猫压力表',
pointAddressID: 4,
},*/
/* {
deviceCode: 'EGJZ00000226',
sensors: '出水压力',
deviceType: '二供机组',
pointAddressID: 4,
}, */
{
"deviceCode": "EGJZ00000163",
"sensors": "进水压力,是否在线",
"deviceType": "二供机组"
"deviceCode": "LLJ00000055",
"sensors": "正累计流量,瞬时流量,是否在线",
"deviceType": "流量计"
}
/* {
"deviceCode": "EGJZ00000163",
"sensors": "进水压力,是否在线",
"deviceType": "二供机组"
}*/
];
const Demo = () => {
return (
......
......@@ -2,18 +2,18 @@ import React, {useEffect, useState} from 'react';
import {MobileHistoryChart} from "../mobile";
import moment from 'moment'
const deviceParams = [
/* {
{
deviceCode: 'EGBF00000141',
sensors: '今日供水量,今日用电量',
deviceType: '二供泵房',
pointAddressID: 208,
}, */
{
},
/* {
deviceCode: 'EGBF00000141',
sensors: '今日供水量',
deviceType: '二供泵房',
pointAddressID: 208,
},
},*/
];
const Demo = () => {
......
......@@ -682,7 +682,11 @@ const HistoryView = (props) => {
return Promise.resolve();
});
};
const handleTime = (diffDays, base = 1000) => {
let unit = 'min', zoom = 0;
zoom = Math.ceil(diffDays * 24 * 60 / 1000).toFixed();
return {unit, zoom};
}
const handleDataThinKey = (diffDays) => {
// edit by zy 根据选择的时长控制抽稀频度
if (diffDays >= 7 && diffDays < 15) {
......@@ -735,7 +739,8 @@ const HistoryView = (props) => {
isBoxPlots: isBoxPlots,
};
let diffDays = moment(item.dateTo).diff(moment(item.dateFrom), 'days');
let zoomParam = activeTabKey === 'curve' ? handleDataThinKey(diffDays) : {};
// let zoomParam = activeTabKey === 'curve' ? handleDataThinKey(diffDays) : {};
let zoomParam = activeTabKey === 'curve' ? handleTime(diffDays,50) : {};
requestArr.push(getHistoryInfo({...param, ...zoomParam}));
});
setLoading(true);
......@@ -790,7 +795,6 @@ const HistoryView = (props) => {
}, [dateRange, dataConfig, deviceParams, chartType]);
const handleChange = (pagination, filter, sort) => {
if (sort.field === 'time') {
debugger
setTimeOrder(sort.order)
}
};
......
......@@ -316,7 +316,7 @@ const seriesTemplate = (param, unit) => {
if (!param) return '';
const {value, encode} = param;
// const val = value[encode.y[0]];
const _unit = unit || 'Mpa';
const _unit = unit || '';
const color = '#008CFF';
if (!isArray(value))
return ` <div style="display: flex; align-items: center;">
......@@ -362,11 +362,11 @@ const tooltipAccessor = (unit) => {
if (isArray(params)) {
tooltipHeader = headTemplate(params[0]);
params.forEach((param) => {
tooltipContent += seriesTemplate(param, unit);
tooltipContent += seriesTemplate(param, unit?.[param?.seriesIndex]);
});
} else {
tooltipHeader = headTemplate(params);
tooltipContent += seriesTemplate(params, unit);
tooltipContent += seriesTemplate(params, unit?.[params?.seriesIndex]);
}
return `
<div>
......@@ -626,9 +626,9 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
}) || []; //当存在othersData的时候,只是单曲线
xAxis = {type: 'time'};
decorateAxisGridLine(xAxis, showGridLine);
let unit = '';
let unit = [];
series = series.map((item) => {
if (item.unit) unit = item.unit;
if (item.unit) unit.push(item.unit);
item.areaStyle = null;
return {...item, symbol: 'none'};
});
......@@ -725,7 +725,7 @@ const optionGenerator = (dataSource, cusOption, contrast, contrastOption, smooth
};
}
} else {
tooltip = tooltipAccessor();
tooltip = tooltipAccessor(series.map(item => item.unit));
}
tooltip.timeFormat = tooltipTimeFormat;
let _legendData = series.filter(item => !['最大值', '最小值'].includes(item.name)).map(item => item.name);
......
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