Update bootstrap and chart.js

This commit is contained in:
Alejandro Celaya
2023-08-08 13:01:27 +02:00
parent f420c7f767
commit 221eb7605f
3 changed files with 37 additions and 22 deletions

View File

@@ -38,7 +38,8 @@ const generateChartData = (labels: string[], data: number[]): ChartData => ({
});
export const DoughnutChart: FC<DoughnutChartProps> = memo(({ stats }) => {
const [chartRef, setChartRef] = useState<Chart | undefined>(); // Cannot use useRef here
// Cannot use useRef here, as we need to re-render as soon as the ref is set
const [chartRef, setChartRef] = useState<Chart>();
const labels = keys(stats);
const data = values(stats);
@@ -61,7 +62,9 @@ export const DoughnutChart: FC<DoughnutChartProps> = memo(({ stats }) => {
data={chartData as any}
options={options as any}
ref={(element) => {
setChartRef(element ?? undefined);
if (element) {
setChartRef(element as Chart);
}
}}
/>
</div>