简体   繁体   English

如何在 Codesandbox 上的 ChartJS 中使用 React 设置简单的饼图

[英]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.遵循react-chartjs-2文档并在代码和框上设置饼图可以使一切正常,但选项不起作用。

When you set up react-chartjs-2 with import { Pie } from "react-chartjs-2";当您使用import { Pie } from "react-chartjs-2";设置react-chartjs-2 -chartjs-2 时; , codesandbox will automatically save the latest stable release of react-chartjs-2 and chart.js as dependencies. ,codesandbox 会自动保存最新的稳定版react-chartjs-2chart.js作为依赖。 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.我制作了一个demo ,可以将其分叉以保留所有依赖项。 It also demos a few options that can be adjusted on the chart.它还演示了一些可以在图表上调整的选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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