简体   繁体   中英

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

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

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.

在此处输入图像描述

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM