简体   繁体   English

Angular Chart.js,如何删除系列?

[英]Angular Chart.js, how to remove series?

I am working on Angular Charts to show line chart in my app. 我正在使用Angular Charts在我的应用程序中显示折线图。 I have integrated line chart using Chart.js. 我已经使用Chart.js集成了折线图。 But, in my graph, I would not want Series displaying after chart. 但是,在我的图形中,我不希望Series在图表之后显示。

My code of chart is 我的图表代码是

 $scope.labels = ["January", "February", "March", "April", "May", "June", "July"];
 $scope.series = ['Series A'];
 $scope.data = [
        [65, 59, 80, 81, 56, 55, 40]
      ];

and my html to show this chart is 和我的HTML来显示此图表是

<canvas id="line" class="chart chart-line" chart-data="data" chart-labels="labels" chart-legend="true" chart-series="series"></canvas>

When I tried to remove Series from code to hide it in graph, Graph is not load. 当我尝试从代码中删除Series以将其隐藏在图中时,不会加载Graph。

Does anyone knows how to remove it without any error? 有谁知道如何删除它而没有任何错误?

Just set the values to null and hide the tooltips 只需将值设置为null并隐藏工具提示

  var a = $scope.data.pop();
  $scope.data.push(a.map(function() { return null; }))
  $scope.options = { showTooltips: false };

Fiddle - http://jsfiddle.net/rt6zoL4k/ 小提琴-http: //jsfiddle.net/rt6zoL4k/

You just have to set the value of display under legend to false. 您只需要将图例下的显示值设置为false。

$scope.options = {
    legend: { display: false }
};

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

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