基于数据集的ChartJS条形图图例过滤器(隐藏)

时间:2019-07-05 15:40:53

标签: javascript vue.js chart.js

我正在使用VueChartJS创建图表,并且当没有数据时,我想隐藏图表的图例。

在阅读CharJS时,它说您可以在图例中放置一个函数过滤器,例如

        legend: {
                  filter: function(data, chart) {

                  //filter out "Honda" legend where the data is 0 or null
                  return true;
                  }
                },

在这种情况下,我想隐藏紫色的“ Honda”图例,因为其值是0或没有数据。我创建了一个小提琴以在https://codepen.io/anon/pen/OeoWWL上解决这个问题,但似乎无法使它奏效。

enter image description here

0 个答案:

没有答案
相关问题