File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ export const ChartCanvas = ({ measurementsInChart }: Props) => {
5959 if ( chart . current )
6060 chartDataSeries . current . set ( measurement . id , [ chart . current . addLineSeries ( { color : measurement . color } ) , measurement . getUpdate ] ) ;
6161 } ) ;
62- } , [ measurementsInChart . length ] )
62+ } )
6363
6464 useGlobalTicker ( ( ) => {
6565 const now = Date . now ( ) / 1000 as UTCTimestamp ;
Original file line number Diff line number Diff line change @@ -15,15 +15,15 @@ type Props = {
1515// React component that keeps the chart render and measurements represented on it.
1616export const ChartElement = memo ( ( { chartId, initialMeasurementId, removeChart } : Props ) => {
1717
18- console . log ( "ChartElement rendered" )
19-
2018 const getNumericMeasurementInfo = useMeasurementsStore ( state => state . getNumericMeasurementInfo ) ;
2119 const initialMeasurement = getNumericMeasurementInfo ( initialMeasurementId ) ;
2220
2321 const [ measurementsInChart , setMeasurementsInChart ] = useState ( [ initialMeasurement ] ) ;
2422
2523 const addMeasurementToChart = ( measurement : NumericMeasurementInfo ) => {
26- setMeasurementsInChart ( [ ...measurementsInChart , measurement ] ) ;
24+ if ( ! measurementsInChart . some ( measurementInChart => measurementInChart . id === measurement . id ) ) {
25+ setMeasurementsInChart ( [ ...measurementsInChart , measurement ] ) ;
26+ }
2727 }
2828
2929 const removeMeasurementFromChart = useCallback ( ( measurementId : MeasurementId ) => {
Original file line number Diff line number Diff line change @@ -19,8 +19,6 @@ type Props = {
1919
2020export const ChartMenu = memo ( ( { sidebarSections } : Props ) => {
2121
22- console . log ( "ChartMenu rendered" )
23-
2422 const getNumericMeasurementInfo = useMeasurementsStore ( ( state ) => state . getNumericMeasurementInfo ) ;
2523
2624 const [ charts , setCharts ] = useState < ChartInfo [ ] > ( [ ] ) ;
You can’t perform that action at this time.
0 commit comments