简体   繁体   English

ChartJS 3 不显示图例

[英]ChartJS 3 doesn't display legend

I'm using ChartJS 3.7 and even when I pass options.plugins.legend.display a true , the legend isn't displayed.我正在使用 ChartJS 3.7,即使我通过options.plugins.legend.display一个true ,也不会显示图例。 How do I get the legend to show?如何让图例显示?

Looks like newer versions of ChartJS require you to register the individual elements you're going to use.看起来较新版本的 ChartJS 要求您注册要使用的各个元素。 You need to register the legend specifically.您需要专门注册图例。

import { Chart, Legend } from 'chart.js';
// ...
Chart.register(Legend);

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

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