1
0
Fork 0

Chart Labels fix

This commit is contained in:
Neshura 2023-06-02 01:22:41 +02:00
parent aefecaedd7
commit 7f90fd1a80
Signed by: Neshura
GPG key ID: B6983AAA6B9A7A6C

View file

@ -3,7 +3,7 @@
import useSWR from "swr";
import { Chart as ChartJS, registerables } from 'chart.js';
import { Pie } from "react-chartjs-2";
import ChartDataLabels from 'chartjs-plugin-datalabels';
import ChartDataLabels, { Context } from 'chartjs-plugin-datalabels';
import { Species } from '../../types/stellaris';
const fetcher = async (url:any) => await fetch(url).then((res) => res.json());
@ -74,7 +74,7 @@ export const PopChart = () => {
display: true
},
datalabels: {
formatter: (value: any, context: any) => {
formatter: (value: any, context: Context) => {
if (value > 0) {
return Species[context.dataIndex];
}
@ -82,8 +82,7 @@ export const PopChart = () => {
return "";
}
},
anchor: 'center',
align: 'end',
color: 'black'
},
},