From 93b5a945a4e7432de6b3f39fedd88ff219e6231c Mon Sep 17 00:00:00 2001 From: Palash <88981777+palash-signoz@users.noreply.github.com> Date: Tue, 28 Sep 2021 18:20:14 +0530 Subject: [PATCH] fix: Chart.js plugins are not register at each and every render (#303) --- frontend/src/components/Graph/index.tsx | 35 ++++++++++++------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/frontend/src/components/Graph/index.tsx b/frontend/src/components/Graph/index.tsx index bb14085d62..f4706e07a6 100644 --- a/frontend/src/components/Graph/index.tsx +++ b/frontend/src/components/Graph/index.tsx @@ -28,6 +28,23 @@ import { useThemeSwitcher } from 'react-css-theme-switcher'; // import Legends from './Legend'; // import { LegendsContainer } from './styles'; +Chart.register( + LineElement, + PointElement, + LineController, + CategoryScale, + LinearScale, + TimeScale, + TimeSeriesScale, + Decimation, + Filler, + Legend, + Title, + Tooltip, + SubTitle, + BarController, + BarElement, +); const Graph = ({ data, @@ -62,24 +79,6 @@ const Graph = ({ } if (chartRef.current !== null) { - Chart.register( - LineElement, - PointElement, - LineController, - CategoryScale, - LinearScale, - TimeScale, - TimeSeriesScale, - Decimation, - Filler, - Legend, - Title, - Tooltip, - SubTitle, - BarController, - BarElement, - ); - const options: ChartOptions = { responsive: true, maintainAspectRatio: false,