Commit e7d50f66 authored by 陈龙's avatar 陈龙

fix: 修复夜间模式分割线异常

parent 09726d19
import React, { memo, useEffect, useMemo, useRef } from 'react'; import React, {memo, useEffect, useMemo, useRef} from 'react';
import { BasicChart } from '@wisdom-components/basicchart'; import {BasicChart} from '@wisdom-components/basicchart';
import optionGenerator, { import optionGenerator, {
alarmMarkLine, alarmMarkLine,
specialTypeChartOptionGenerator, specialTypeChartOptionGenerator,
} from './utils'; } from './utils';
import { isArray, cloneDeep } from 'lodash'; import {isArray, cloneDeep} from 'lodash';
import moment from "moment"; import moment from "moment";
import patchBIOption from "./useBIMode"; import patchBIOption from "./useBIMode";
import { BI, Normal } from './theme'; import {BI, Normal} from './theme';
import * as echarts from 'echarts'; import * as echarts from 'echarts';
echarts.registerTheme('BI', BI) echarts.registerTheme('BI', BI)
...@@ -58,9 +58,9 @@ const SingleChart = memo((props) => { ...@@ -58,9 +58,9 @@ const SingleChart = memo((props) => {
if (dataSource.length === 1 && SpecialType.includes(_allPointAddress[dataSource[0].sensorName])) { if (dataSource.length === 1 && SpecialType.includes(_allPointAddress[dataSource[0].sensorName])) {
config.sensorType = _allPointAddress[dataSource[0].sensorName]; config.sensorType = _allPointAddress[dataSource[0].sensorName];
config.special.allValDesc = allValDesc; config.special.allValDesc = allValDesc;
return specialTypeChartOptionGenerator({ dataSource, config }); return specialTypeChartOptionGenerator({dataSource, config});
} }
let _option = optionGenerator(dataSource, null, contrast, contrastOption, smooth, config, lineDataType, predicateData); let _option = optionGenerator(dataSource, null, contrast, contrastOption, smooth, config, lineDataType, predicateData,theme);
if (emptyOrError.empty || emptyOrError.error) { if (emptyOrError.empty || emptyOrError.error) {
if (isArray(_option.yAxis)) { if (isArray(_option.yAxis)) {
_option.yAxis.forEach(item => { _option.yAxis.forEach(item => {
...@@ -81,7 +81,7 @@ const SingleChart = memo((props) => { ...@@ -81,7 +81,7 @@ const SingleChart = memo((props) => {
const chart = chartRef.current?.getEchartsInstance?.(); const chart = chartRef.current?.getEchartsInstance?.();
function hander(params) { function hander(params) {
const { selected } = params; const {selected} = params;
const count = Object.values(selected || {}).filter((item) => item).length; const count = Object.values(selected || {}).filter((item) => item).length;
const option = cloneDeep(chart.getOption()); const option = cloneDeep(chart.getOption());
const needMarkLine = count === 1; const needMarkLine = count === 1;
...@@ -120,8 +120,8 @@ const SingleChart = memo((props) => { ...@@ -120,8 +120,8 @@ const SingleChart = memo((props) => {
let minPoint = pointArr[minValueIndex]; let minPoint = pointArr[minValueIndex];
if (!maxPoint || !minPoint) return {} if (!maxPoint || !minPoint) return {}
// 3. 计算坐标位置,返回的是 [x,y]的像素坐标 // 3. 计算坐标位置,返回的是 [x,y]的像素坐标
let maxPointPosition = chart.convertToPixel({ seriesIndex: 0 }, [moment(maxPoint.pt).valueOf(), maxPoint.pv]) let maxPointPosition = chart.convertToPixel({seriesIndex: 0}, [moment(maxPoint.pt).valueOf(), maxPoint.pv])
let minPointPosition = chart.convertToPixel({ seriesIndex: 0 }, [moment(minPoint.pt).valueOf(), minPoint.pv]) let minPointPosition = chart.convertToPixel({seriesIndex: 0}, [moment(minPoint.pt).valueOf(), minPoint.pv])
if (!maxPointPosition || !minPointPosition) return; if (!maxPointPosition || !minPointPosition) return;
// 4. 计算最大最小值的标签宽度 // 4. 计算最大最小值的标签宽度
let maxLength = 80 + String(maxValue).length * 5; let maxLength = 80 + String(maxValue).length * 5;
...@@ -236,14 +236,14 @@ const SingleChart = memo((props) => { ...@@ -236,14 +236,14 @@ const SingleChart = memo((props) => {
name: '', name: '',
type: 'max', type: 'max',
symbol: 'emptyCircle', symbol: 'emptyCircle',
label: { show: false }, label: {show: false},
symbolSize: 6, symbolSize: 6,
}, },
{ {
name: '', name: '',
type: 'min', type: 'min',
symbol: 'emptyCircle', symbol: 'emptyCircle',
label: { show: false }, label: {show: false},
symbolSize: 6, symbolSize: 6,
} }
]; ];
...@@ -259,7 +259,7 @@ const SingleChart = memo((props) => { ...@@ -259,7 +259,7 @@ const SingleChart = memo((props) => {
}; };
}; };
// minMaxMarkPoint(dataSource) // minMaxMarkPoint(dataSource)
chart.setOption({ series: { markPoint: minMaxMarkPoint(dataSource) } }) chart.setOption({series: {markPoint: minMaxMarkPoint(dataSource)}})
}, 200) }, 200)
} }
...@@ -298,15 +298,19 @@ const SingleChart = memo((props) => { ...@@ -298,15 +298,19 @@ const SingleChart = memo((props) => {
show: theme === 'BI' ? false : showGridLine, show: theme === 'BI' ? false : showGridLine,
lineStyle: { lineStyle: {
type: 'dashed', type: 'dashed',
...(theme === 'BI' ? {color: '#38435a'} : {})
}, },
}, },
splitLine: { splitLine: {
show: showGridLine, show: showGridLine,
lineStyle: {
...(theme === 'BI' ? {color: '#38435a'} : {})
},
}, },
}; };
let yAxis = axisConfig; let yAxis = axisConfig;
if (isArray(option.yAxis)) { if (isArray(option.yAxis)) {
yAxis = option.yAxis.map((item) => ({ ...axisConfig })); yAxis = option.yAxis.map((item) => ({...axisConfig}));
} }
let xAxis = axisConfig; let xAxis = axisConfig;
chart.setOption({ chart.setOption({
...@@ -316,7 +320,7 @@ const SingleChart = memo((props) => { ...@@ -316,7 +320,7 @@ const SingleChart = memo((props) => {
}); });
}, [showGridLine]); }, [showGridLine]);
return <BasicChart theme={theme} ref={chartRef} option={option} notMerge return <BasicChart theme={theme} ref={chartRef} option={option} notMerge
style={{ width: '100%', height: '100%' }} /> style={{width: '100%', height: '100%'}}/>
}); });
export default SingleChart; export default SingleChart;
...@@ -215,13 +215,13 @@ const deviceParams = [ ...@@ -215,13 +215,13 @@ const deviceParams = [
"deviceCode": "SC00000004", "deviceCode": "SC00000004",
"sensors": "进水瞬时流量,1#出水瞬时流量,2#出水瞬时流量", "sensors": "进水瞬时流量,1#出水瞬时流量,2#出水瞬时流量",
"deviceType": "水厂" "deviceType": "水厂"
} },
/* { /* {
"deviceCode": "EGJZ00000073", "deviceCode": "EGJZ00000073",
"sensors": "进水压力", "sensors": "进水压力",
"deviceType": "二供机组" "deviceType": "二供机组"
}*/ },
/* { {
"deviceCode": "EGJZ00000006", "deviceCode": "EGJZ00000006",
"sensors": "进水压力", "sensors": "进水压力",
"deviceType": "二供机组" "deviceType": "二供机组"
......
...@@ -1237,7 +1237,7 @@ const HistoryView = (props) => { ...@@ -1237,7 +1237,7 @@ const HistoryView = (props) => {
} }
}).filter((item) => item.sensorName); }).filter((item) => item.sensorName);
// 预测的 // 预测的
data = data.concat(list.filter(item => item.deviceType !== '预测')); // data = data.concat(list.filter(item => item.deviceType !== '预测'));
// _predicateData = _predicateData.concat(list.filter(item => item.deviceType === '预测')); // _predicateData = _predicateData.concat(list.filter(item => item.deviceType === '预测'));
}); });
} }
......
...@@ -50,18 +50,6 @@ ...@@ -50,18 +50,6 @@
color: var(--text-color); color: var(--text-color);
} }
&-label {
position: relative;
width: 80px;
color: @primaryTextColor;
&::after {
position: absolute;
top: 0;
right: 7px;
content: ':';
}
}
// radio // radio
:global { :global {
...@@ -221,22 +209,28 @@ ...@@ -221,22 +209,28 @@
} }
} }
.@{history-view} { .historyViewComponents.@{history-view} {
height: 100%; height: 100%;
padding: @padding-md; padding: @padding-md;
//background: ;
.@{ant-prefix}-tabs-extra-content { .@{ant-prefix}-tabs-extra-content {
width: 82px; width: 82px;
white-space: nowrap; white-space: nowrap;
} }
&-label {
position: relative;
width: 80px;
color: @primaryTextColor;
&::after {
position: absolute;
top: 0;
right: 7px;
content: ':';
}
}
&-extra-right { &-extra-right {
position: absolute; position: absolute;
...@@ -496,4 +490,4 @@ ...@@ -496,4 +490,4 @@
100% { 100% {
opacity: 1; opacity: 1;
} }
} }
\ No newline at end of file
...@@ -15,7 +15,7 @@ const handleYAxis = (item, _opt) => { ...@@ -15,7 +15,7 @@ const handleYAxis = (item, _opt) => {
show: false, show: false,
lineStyle: { lineStyle: {
type: 'solid', type: 'solid',
color: BISplitLineColor color: '#38435a'
} }
}; };
item.splitLine = { item.splitLine = {
......
...@@ -191,28 +191,36 @@ export const alarmMarkLine = (dataItem, index, dataSource, schemes) => { ...@@ -191,28 +191,36 @@ export const alarmMarkLine = (dataItem, index, dataSource, schemes) => {
* 坐标轴添加网格线配置 * 坐标轴添加网格线配置
* *
* @param {any} axis * @param {any} axis
* @param showGrid
* @param theme
*/ */
export const decorateAxisGridLine = (axis, showGrid) => { export const decorateAxisGridLine = (axis, showGrid, theme) => {
if (!axis) return; if (!axis) return;
axis.minorTick = { axis.minorTick = {
lineStyle: {
// color: '#e2e2e2',
},
...(axis.minorTick || {}), ...(axis.minorTick || {}),
...(theme === 'BI' ? {
lineStyle: {
...(theme === 'BI' ? {color: 'rgba(56,67,90,0.81)'} : {})
},
} : {}),
show: showGrid, show: showGrid,
splitNumber: 2, splitNumber: 2,
}; };
axis.minorSplitLine = { axis.minorSplitLine = {
lineStyle: {
// color: '#e2e2e2',
// type: 'dashed',
},
...(axis.minorSplitLine || {}), ...(axis.minorSplitLine || {}),
show: showGrid, ...(theme === 'BI' ? {
lineStyle: {
...(theme === 'BI' ? {color: 'rgba(56,67,90,0.81)'} : {})
},
} : {}),
show: false,
}; };
axis.splitLine = { axis.splitLine = {
...(axis.splitLine || {}), ...(axis.splitLine || {}),
show: showGrid, show: showGrid,
lineStyle: {
...(theme === 'BI' ? {color: 'rgba(56,67,90,0.81)'} : {})
},
}; };
}; };
...@@ -483,7 +491,7 @@ const returnXAxis = ({ ...@@ -483,7 +491,7 @@ const returnXAxis = ({
// let markPoint = showPoint ? minMaxMarkPoint(item, index, dataSource) : {}; // let markPoint = showPoint ? minMaxMarkPoint(item, index, dataSource) : {};
let markPoint = {}; let markPoint = {};
let _lineStyle = {}; let _lineStyle = {};
if (item.deviceType === '预测' && chartType === 'lineChart') { /* if (item.deviceType === '预测' && chartType === 'lineChart') {
markPoint = null; markPoint = null;
markLine = null; markLine = null;
_lineStyle = { _lineStyle = {
...@@ -494,7 +502,7 @@ const returnXAxis = ({ ...@@ -494,7 +502,7 @@ const returnXAxis = ({
type: 'dashed', type: 'dashed',
} }
} }
} }*/
return { return {
notMerge: true, notMerge: true,
name, name,
...@@ -633,9 +641,10 @@ const reduceYAxis = (arr, dataSource) => { ...@@ -633,9 +641,10 @@ const reduceYAxis = (arr, dataSource) => {
* @param {boolean} needUnit 是否显示单位。 * @param {boolean} needUnit 是否显示单位。
* @param {boolean} curveCenter 曲线是否居中。 * @param {boolean} curveCenter 曲线是否居中。
* @param {boolean} showGridLine 是否显示网格线。 * @param {boolean} showGridLine 是否显示网格线。
* @param theme
* @returns {object} 返回左右轴的margin、yAxis的配置。 * @returns {object} 返回左右轴的margin、yAxis的配置。
*/ */
const handleYAxis = ({dataSource, needUnit, curveCenter, showGridLine}) => { const handleYAxis = ({dataSource, needUnit, curveCenter, showGridLine, theme}) => {
const yAxisMap = new Map(); const yAxisMap = new Map();
// 1. 找出最大值; 2. 计算出y轴最大宽度动态计算偏移距离; // 1. 找出最大值; 2. 计算出y轴最大宽度动态计算偏移距离;
dataSource.forEach((item, index) => { dataSource.forEach((item, index) => {
...@@ -676,7 +685,7 @@ const handleYAxis = ({dataSource, needUnit, curveCenter, showGridLine}) => { ...@@ -676,7 +685,7 @@ const handleYAxis = ({dataSource, needUnit, curveCenter, showGridLine}) => {
} }
// 网格显示 // 网格显示
const axis = yAxisMap.get(key); const axis = yAxisMap.get(key);
decorateAxisGridLine(axis, showGridLine); decorateAxisGridLine(axis, showGridLine, theme);
}); });
const yAxis = const yAxis =
yAxisMap.size > 0 ? reduceYAxis([...yAxisMap.values()], dataSource) : {type: 'value'}; yAxisMap.size > 0 ? reduceYAxis([...yAxisMap.values()], dataSource) : {type: 'value'};
...@@ -742,7 +751,7 @@ const assignOptions = ( ...@@ -742,7 +751,7 @@ const assignOptions = (
...{ ...{
show: true, show: true,
right: 10, right: 10,
top: 30, top: 10,
icon: 'rect', icon: 'rect',
itemWidth: 14, itemWidth: 14,
itemHeight: 8, itemHeight: 8,
...@@ -791,9 +800,9 @@ const returnMaxOrMinNumber = (dataSource, type) => { ...@@ -791,9 +800,9 @@ const returnMaxOrMinNumber = (dataSource, type) => {
return _value; return _value;
}; };
const handleGrid = (dataSource, needUnit, leftNum, rightNum, chartType) => { const handleGrid = (dataSource, needUnit, theme) => {
// 如果是单曲线,_grid的top需要一行的高度,用来放置最值最小值 // 如果是单曲线,_grid的top需要一行的高度,用来放置最值最小值
let _base = 60; let _base = 40
let _topForUnit = needUnit ? 20 : 0; let _topForUnit = needUnit ? 20 : 0;
return { return {
top: _base + _topForUnit, top: _base + _topForUnit,
...@@ -915,6 +924,7 @@ const renderStatusItem = (params, api) => { ...@@ -915,6 +924,7 @@ const renderStatusItem = (params, api) => {
* @param {any} config 额外配置信息 * @param {any} config 额外配置信息
* @param lineDataType * @param lineDataType
* @param predicateData * @param predicateData
* @param theme
*/ */
const optionGenerator = ( const optionGenerator = (
...@@ -925,7 +935,8 @@ const optionGenerator = ( ...@@ -925,7 +935,8 @@ const optionGenerator = (
smooth, smooth,
config, config,
lineDataType = '', lineDataType = '',
predicateData predicateData,
theme = 'Normal'
) => { ) => {
// 1. 处理配置,配置分配默认值; // 1. 处理配置,配置分配默认值;
const { const {
...@@ -946,6 +957,7 @@ const optionGenerator = ( ...@@ -946,6 +957,7 @@ const optionGenerator = (
needUnit, needUnit,
curveCenter, curveCenter,
showGridLine, showGridLine,
theme
}); });
let {xAxis, series, visualMap} = returnXAxis({ let {xAxis, series, visualMap} = returnXAxis({
dataSource, dataSource,
...@@ -963,8 +975,8 @@ const optionGenerator = ( ...@@ -963,8 +975,8 @@ const optionGenerator = (
chartType chartType
}); });
// 3. 判断是否开启网格; // 3. 判断是否开启网格;
const grid = handleGrid(dataSource, needUnit, leftNum, rightNum, chartType); const grid = handleGrid(dataSource, needUnit, theme);
decorateAxisGridLine(xAxis, showGridLine); decorateAxisGridLine(xAxis, showGridLine, theme);
const tooltipTimeFormat = !contrast const tooltipTimeFormat = !contrast
? 'YYYY-MM-DD HH:mm:ss' ? 'YYYY-MM-DD HH:mm:ss'
: contrastOption === 'day' : contrastOption === 'day'
...@@ -980,7 +992,7 @@ const optionGenerator = ( ...@@ -980,7 +992,7 @@ const optionGenerator = (
return [moment(pt).valueOf(), firstPV, lastPV, minPV, maxPV]; return [moment(pt).valueOf(), firstPV, lastPV, minPV, maxPV];
}) || []; //当存在othersData的时候,只是单曲线 }) || []; //当存在othersData的时候,只是单曲线
xAxis = {type: 'time'}; xAxis = {type: 'time'};
decorateAxisGridLine(xAxis, showGridLine); decorateAxisGridLine(xAxis, showGridLine, theme);
let unit = []; let unit = [];
series = series.map((item) => { series = series.map((item) => {
if (item.unit) unit.push(item.unit); if (item.unit) unit.push(item.unit);
...@@ -1034,7 +1046,7 @@ const optionGenerator = ( ...@@ -1034,7 +1046,7 @@ const optionGenerator = (
}); //当存在othersData的时候,只是单曲线 }); //当存在othersData的时候,只是单曲线
// xAxis = {type: 'category', data: series[0].data.map(item => moment(item[0]).format('YYYY-MM-DD HH:mm:ss'))}; // xAxis = {type: 'category', data: series[0].data.map(item => moment(item[0]).format('YYYY-MM-DD HH:mm:ss'))};
xAxis = {type: 'time'}; xAxis = {type: 'time'};
decorateAxisGridLine(xAxis, showGridLine); decorateAxisGridLine(xAxis, showGridLine, theme);
let _unit = ''; let _unit = '';
series = series.map((item) => { series = series.map((item) => {
_unit = item.unit ?? ''; _unit = item.unit ?? '';
......
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