How to set up a simple pie chart using React in ChartJS on codesandbox

318 Views Asked by At

Following the react-chartjs-2 documentation and setting up a Pie chart on codesandbox gets everything working, except the options don't work.

1

There are 1 best solutions below

0
On BEST ANSWER

When you set up react-chartjs-2 with import { Pie } from "react-chartjs-2";, codesandbox will automatically save the latest stable release of react-chartjs-2 and chart.js as dependencies. This unfortunately breaks things. You need to change the versions in this panel on the left hand side of your codesandbox panels.

enter image description here

I've made a demo, which can be forked to keep all of the dependencies. It also demos a few options that can be adjusted on the chart.