From 0a27ccdfef70a9c07c55889271f4ceaf949fd2af Mon Sep 17 00:00:00 2001 From: goodmice Date: Mon, 15 Nov 2021 10:58:22 +0500 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=20=D0=BE=D0=B4=D0=B8=D0=BD=D0=B0=D0=BA=D0=BE=D0=B2=D1=8B=D1=85?= =?UTF-8?q?=20=D1=82=D0=BE=D1=87=D0=B5=D0=BA=20=D0=B8=20=D0=BE=D0=B1=D1=80?= =?UTF-8?q?=D0=B5=D0=B7=D0=BA=D0=B0=20=D0=BF=D0=BE=20pointCount?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/TelemetryView/MonitoringColumn.jsx | 23 +++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/pages/TelemetryView/MonitoringColumn.jsx b/src/pages/TelemetryView/MonitoringColumn.jsx index 91ef8ed..fab0fc3 100644 --- a/src/pages/TelemetryView/MonitoringColumn.jsx +++ b/src/pages/TelemetryView/MonitoringColumn.jsx @@ -19,6 +19,14 @@ const GetLimitShape = (flowChartData, points, accessor) => { return min.concat(max.reverse()) ?? [] } +const RemoveSimilar = (input) => { + const data = [input[0]] + for (let i = 1; i < input.length; i++) + if (input[i].y !== input[i - 1].y) + data.push(input[i]) + return data +} + export const MonitoringColumn = ({ lineGroup, data, flowChartData, interval, showBorder, style, headerHeight, pointCount }) => { const [lineGroupWithoutShapes, setLineGroupWithoutShapes] = useState([]) const dataLast = data?.[data.length - 1] @@ -31,16 +39,20 @@ export const MonitoringColumn = ({ lineGroup, data, flowChartData, interval, sho })) const postParsing = (data) => { - if (flowChartData) { - lineGroupWithoutShapes.forEach(lineCfg => { - const lineDataSet = GetOrCreateDatasetByLineConfig(data.data, lineCfg) + lineGroupWithoutShapes.forEach(lineCfg => { + const lineDataSet = GetOrCreateDatasetByLineConfig(data.data, lineCfg) + lineDataSet.data = RemoveSimilar(lineDataSet.data) + if (lineDataSet.data.length > pointCount) + lineDataSet.data.splice(0, pointCount - lineDataSet.data.length) + + if (flowChartData) { lineGroup.filter(cfg => cfg.isShape && cfg.xAccessorName === lineCfg.xAccessorName).forEach(areaCfg => { const dataset = GetOrCreateDatasetByLineConfig(data.data, areaCfg) dataset.data = GetLimitShape(flowChartData, lineDataSet.data, areaCfg.xAccessorName) }) - }) - } + } + }) } useEffect(() => { @@ -68,7 +80,6 @@ export const MonitoringColumn = ({ lineGroup, data, flowChartData, interval, sho yDisplay={false} yStart={yStart} savePreviousData={true} - pointCount={pointCount} />