forked from ddrilling/asb_cloud_front
Column use memo added
This commit is contained in:
parent
80622351f8
commit
e803a9172b
@ -1,4 +1,4 @@
|
|||||||
import { useState, useEffect } from 'react'
|
import React, { useState, useEffect } from 'react'
|
||||||
import { ChartTimeBase } from './ChartTimeBase'
|
import { ChartTimeBase } from './ChartTimeBase'
|
||||||
|
|
||||||
const chartPluginsOptions = {
|
const chartPluginsOptions = {
|
||||||
@ -45,8 +45,10 @@ export const GetOrCreateDatasetByLineConfig = (data, lineConfig) => {
|
|||||||
return dataset
|
return dataset
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Column = ({ lineGroup, data, postParsing, interval, yDisplay, yStart, pointCount, savePreviousData }) => {
|
export const Column = React.memo(({ lineGroup, data, postParsing, interval, yDisplay, yStart, pointCount, savePreviousData }) => {
|
||||||
const [dataParams, setDataParams] = useState({data: {datasets:[]}, yStart, })
|
const [dataParams, setDataParams] = useState({data: {datasets:[]}, yStart, })
|
||||||
|
if (!pointCount || !Number.isInteger(pointCount))
|
||||||
|
pointCount = 2048
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if((lineGroup.length === 0) || (data.length === 0)) return
|
if((lineGroup.length === 0) || (data.length === 0)) return
|
||||||
@ -83,9 +85,4 @@ export const Column = ({ lineGroup, data, postParsing, interval, yDisplay, yStar
|
|||||||
}, [data, lineGroup, interval, yDisplay, yStart, postParsing, pointCount, savePreviousData])
|
}, [data, lineGroup, interval, yDisplay, yStart, postParsing, pointCount, savePreviousData])
|
||||||
|
|
||||||
return <ChartTimeBase dataParams = { dataParams } options = { chartPluginsOptions } />
|
return <ChartTimeBase dataParams = { dataParams } options = { chartPluginsOptions } />
|
||||||
}
|
})
|
||||||
|
|
||||||
Column.defaultProps = {
|
|
||||||
pointCount: 2048,
|
|
||||||
savePreviousData: false
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user