Добавлено удаление одинаковых точек и обрезка по pointCount

This commit is contained in:
goodmice 2021-11-15 10:58:22 +05:00
parent 6d962a89e3
commit 0a27ccdfef

View File

@ -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}
/>
</div>
<ChartTimeOnlineFooter data={dataLast} lineGroup={lineGroup} />