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} />