Chart Labels fix
This commit is contained in:
parent
aefecaedd7
commit
7f90fd1a80
1 changed files with 3 additions and 4 deletions
|
@ -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'
|
||||
},
|
||||
},
|
||||
|
|
Reference in a new issue