Commit 7dc9aad6 authored by 陈龙's avatar 陈龙

feat: 历史曲线优化表格数据下载的展示

parent 6eac50bd
...@@ -24,6 +24,16 @@ path: / ...@@ -24,6 +24,16 @@ path: /
<code src="./demos/index.js"></code> <code src="./demos/index.js"></code>
## 单图表-状态
[//]: # (<code src="./demos/indexForStatus.js"></code>)
## 单图表-频率
<code src="./demos/indexForFrequency.js"></code>
[//]: # (## 移动端) [//]: # (## 移动端)
[//]: # (<code src="./demos/mobile.js"></code>) [//]: # (<code src="./demos/mobile.js"></code>)
......
...@@ -4,12 +4,12 @@ import { MobileHistoryChart } from "../mobile"; ...@@ -4,12 +4,12 @@ import { MobileHistoryChart } from "../mobile";
const deviceParams = [ const deviceParams = [
/*10.182*/ /*10.182*/
/* { {
"deviceCode": "EGBF00000136", "deviceCode": "EGBF00000136",
// "sensors": "进水压力,出水压力,出水瞬时流量,今日供水量,1#水箱液位,视频报警", "sensors": "进水压力,出水压力,出水瞬时流量,今日供水量,1#水箱液位,视频报警",
"sensors": "视频报警", // "sensors": "视频报警",
"deviceType": "二供泵房" "deviceType": "二供泵房"
},*/ },
{ {
"deviceCode": "EGJZ00000158", "deviceCode": "EGJZ00000158",
// "sensors": "进水压力,出水压力,泵1状态", // "sensors": "进水压力,出水压力,泵1状态",
...@@ -71,11 +71,11 @@ const deviceParams = [ ...@@ -71,11 +71,11 @@ const deviceParams = [
"deviceType": "二供机组" "deviceType": "二供机组"
}*/ }*/
// 邳州张楼水厂 // 邳州张楼水厂
/* { /* {
"deviceCode": "SC00000023", "deviceCode": "SC00000023",
"sensors": "瞬时流量", "sensors": "瞬时流量",
"deviceType": "水厂" "deviceType": "水厂"
}, */ },*/
/* { /* {
"deviceCode": "JFJ00000001", "deviceCode": "JFJ00000001",
"sensors": "沉淀池投矾量瞬时,", "sensors": "沉淀池投矾量瞬时,",
...@@ -121,13 +121,16 @@ const deviceParams = [ ...@@ -121,13 +121,16 @@ const deviceParams = [
"deviceType": "二供泵房" "deviceType": "二供泵房"
}*/ }*/
]; ];
const Demo = () => { const Demo = () => {
return ( return (
<>
<div> <div>
<div style={{ height: 700 }}> <div style={{ height: 700 }}>
<HistoryView deviceParams={deviceParams} defaultModel="curve" /> <HistoryView deviceParams={deviceParams} defaultModel="curve" />
</div> </div>
</div> </div>
</>
); );
}; };
......
import React from 'react';
import HistoryView from '../index';
const deviceParams2 = [
{
deviceCode:'EGJZ00000223',
sensors: '1#变频器运行频率',
deviceType: '二供机组',
}
]
const Demo = () => {
return (
<>
<div>
<div style={{height: 700}}>
<HistoryView deviceParams={deviceParams2} defaultModel="curve"/>
</div>
</div>
</>
);
};
export default Demo;
\ No newline at end of file
import React from 'react';
import HistoryView from '../index';
const deviceParams2 = [
{
"deviceCode": "EGJZ00000319",
// "sensors": "进水压力,出水压力,泵1状态",
// "sensors": "进水压力",
"sensors": "泵1状态",
"deviceType": "二供机组"
}
]
const Demo = () => {
return (
<>
<div>
<div style={{height: 700}}>
<HistoryView deviceParams={deviceParams2} defaultModel="curve"/>
</div>
</div>
</>
);
};
export default Demo;
\ No newline at end of file
...@@ -594,7 +594,6 @@ const handleDefault = (config, cusOption) => { ...@@ -594,7 +594,6 @@ const handleDefault = (config, cusOption) => {
const showPoint = _.get(config, 'showPoint', false); const showPoint = _.get(config, 'showPoint', false);
const deviceAlarmSchemes = _.get(config, 'deviceAlarmSchemes', []); const deviceAlarmSchemes = _.get(config, 'deviceAlarmSchemes', []);
const chartType = _.get(config, 'chartType', null); const chartType = _.get(config, 'chartType', null);
// const justLine = _.get(config, 'justLine', false);
const showBoxOption = _.get(config, 'showBoxOption', false); const showBoxOption = _.get(config, 'showBoxOption', false);
// 自定义属性 // 自定义属性
const restOption = _.pick(cusOption, ['title', 'legend']); const restOption = _.pick(cusOption, ['title', 'legend']);
...@@ -683,17 +682,9 @@ const handleYAxis = ({dataSource, needUnit, curveCenter, showGridLine}) => { ...@@ -683,17 +682,9 @@ const handleYAxis = ({dataSource, needUnit, curveCenter, showGridLine}) => {
const {sensorName, unit} = item; const {sensorName, unit} = item;
const key = sensorName; const key = sensorName;
if (!yAxisMap.has(key)) { if (!yAxisMap.has(key)) {
/* const i = yAxisMap.size;
let _offset = _maxValueArray[i - 2];
let _baseOffset = _offsetValue[i - 2] ?? 0;
let _finalOffset = (_offset !== undefined ? (_offset === 0 ? 2 : _offset.toString().replaceAll('.','').length) * 10 : 0) + _baseOffset;
_offsetValue.push(_finalOffset);*/
const axis = { const axis = {
type: 'value', type: 'value',
name: needUnit ? unit : null, name: needUnit ? unit : null,
// position: i % 2 === 0 ? 'left' : 'right',
// offset: _offset !== undefined ? (_offset === 0? 2:_offset.toString().length) * 10 : 0,
// offset: _finalOffset,
axisLabel: { axisLabel: {
formatter: (value) => { formatter: (value) => {
return handleMaxValue(value); return handleMaxValue(value);
...@@ -780,9 +771,7 @@ const assignOptions = (restOption, xAxis, legendData, chartType, contrast, contr ...@@ -780,9 +771,7 @@ const assignOptions = (restOption, xAxis, legendData, chartType, contrast, contr
restOption.legend = { restOption.legend = {
...{ ...{
show: true, show: true,
// data: legend, right:10,
// selectedMode: false,
left: 'right',
top: 30, top: 30,
icon: 'rect', icon: 'rect',
itemWidth: 14, itemWidth: 14,
...@@ -836,10 +825,8 @@ const handleGrid = (dataSource, needUnit, leftNum, rightNum, chartType) => { ...@@ -836,10 +825,8 @@ const handleGrid = (dataSource, needUnit, leftNum, rightNum, chartType) => {
let _topForUnit = needUnit ? 20 : 0; let _topForUnit = needUnit ? 20 : 0;
return { return {
top: _base + _topForUnit, top: _base + _topForUnit,
// left: leftNum === 1 ? 10 : leftNum * AXIS_WIDTH,
left: 30, left: 30,
right: 10, right: 10,
// right: rightNum === 0 ? 20 : rightNum * AXIS_WIDTH,
bottom: 60, bottom: 60,
containLabel: true, containLabel: true,
}; };
...@@ -1007,7 +994,7 @@ const optionGenerator = ( ...@@ -1007,7 +994,7 @@ const optionGenerator = (
: 'DD HH:mm'; : 'DD HH:mm';
let tooltip = {}; let tooltip = {};
// 增加箱线图的逻辑,单曲线才存在该逻辑 // 增加箱线图的逻辑,单曲线才存在该逻辑
if (chartType && showBoxOption) { if (chartType && showBoxOption && !special?.special1?.name) {
if (chartType === 'boxChart' && lineDataType === '特征曲线') { if (chartType === 'boxChart' && lineDataType === '特征曲线') {
const otherData = const otherData =
dataSource?.[0]?.dataModel.map((item) => { dataSource?.[0]?.dataModel.map((item) => {
...@@ -1022,7 +1009,8 @@ const optionGenerator = ( ...@@ -1022,7 +1009,8 @@ const optionGenerator = (
item.areaStyle = null; item.areaStyle = null;
return {...item, showSymbol: false}; return {...item, showSymbol: false};
}); });
series.push({ // 箱线图去除曲线 2023年10月17日
series=[{
type: 'candlestick', type: 'candlestick',
name: '箱线图', name: '箱线图',
symbol: 'none', symbol: 'none',
...@@ -1033,7 +1021,7 @@ const optionGenerator = ( ...@@ -1033,7 +1021,7 @@ const optionGenerator = (
borderColor: '#FFA200', borderColor: '#FFA200',
borderColor0: '#44CD00', borderColor0: '#44CD00',
}, },
}); }];
tooltip = tooltipAccessor(unit); tooltip = tooltipAccessor(unit);
} }
if (chartType === 'lineChart' || lineDataType === '原始曲线') { if (chartType === 'lineChart' || lineDataType === '原始曲线') {
...@@ -1160,8 +1148,8 @@ const optionGenerator = ( ...@@ -1160,8 +1148,8 @@ const optionGenerator = (
return _options; return _options;
}; };
export default optionGenerator; export default optionGenerator;
const handleDataSource = (dataSource) => { const handleDataSource = (dataSource) => {
let _temp = null; let _temp = null;
let _data = []; let _data = [];
...@@ -1226,14 +1214,14 @@ const handleSpecial2 = (special, sensorName, sensorType, data1, data2) => { ...@@ -1226,14 +1214,14 @@ const handleSpecial2 = (special, sensorName, sensorType, data1, data2) => {
name = _switchNameMap[data1.pv]; name = _switchNameMap[data1.pv];
color = _switchColorMap[data1.pv]; color = _switchColorMap[data1.pv];
} }
;
value1 = moment(data1.pt).valueOf(); value1 = moment(data1.pt).valueOf();
value2 = moment(data2.pt).valueOf(); value2 = moment(data2.pt).valueOf();
return {color, value1, value2, name} return {color, value1, value2, name}
}; };
const handleDataToSeries = (special, sensorName, sensorType, data) => { const handleDataToSeries = (special, sensorName, sensorType, data) => {
let _data = []; let _data = [];
let _legend = [] let _legend = [];
data.forEach((item, index) => { data.forEach((item, index) => {
if (index === data.length - 1) return; if (index === data.length - 1) return;
let {color, value1, value2, name} = handleSpecial2(special, sensorName, sensorType, item, data[index + 1]) let {color, value1, value2, name} = handleSpecial2(special, sensorName, sensorType, item, data[index + 1])
...@@ -1286,7 +1274,7 @@ const specialTypeChartOptionGenerator = ({dataSource, cusOption, contrast, contr ...@@ -1286,7 +1274,7 @@ const specialTypeChartOptionGenerator = ({dataSource, cusOption, contrast, contr
splitLine: { splitLine: {
show: true show: true
}, },
"minInterval": 3600000 minInterval: 3600 * 1000
}; };
let yAxis = { let yAxis = {
data: [dataSource[0].sensorName], data: [dataSource[0].sensorName],
...@@ -1355,13 +1343,13 @@ const specialTypeChartOptionGenerator = ({dataSource, cusOption, contrast, contr ...@@ -1355,13 +1343,13 @@ const specialTypeChartOptionGenerator = ({dataSource, cusOption, contrast, contr
show: true, show: true,
data: legend, data: legend,
selectedMode: false, selectedMode: false,
left: 'right', right: 10,
top: 30, top: 30,
icon: 'rect', icon: 'rect',
itemWidth: 14, itemWidth: 14,
itemHeight: 8, itemHeight: 8,
itemGap: 20, itemGap: 20,
} };
let _option = { let _option = {
xAxis, xAxis,
yAxis, yAxis,
......
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