0

我能够在 angular2-highcharts 中显示图例和图例标题。我计划在图例标题下方显示总计数(在城市下方),但无法找出如何。另外我不确定为什么 % 与图例值中的值一起显示。

我的标签格式化程序是:

  labelFormatter: function () {
      return '<div class="legend-label-md row" style=" border-bottom:1px solid black; margin-bottom: 5px"><span class="col-md-10">' + this.name +
             '</span><span class="col-md-2" >' + this.value +
              '%</span></div> ';
       }

https://plnkr.co/edit/yzXLz7AIDoWa1Pzxxl4k?p=preview

4

1 回答 1

0

每个饼系列点都有该系列的总数,因此您可以更新图表加载事件的图例以包括该系列的总数。

演示:https ://plnkr.co/edit/6JW1KmYE1Lr4pAIWCJTm?p=preview

模板为:

template: `
    <chart  [options]="options" (load)="onLoad($event)">
    </chart>
`

class AppComponent

    onLoad (e) {
                var chart = e.context,
                    total = chart.series[0].points[0].total;
                chart.update({
                    legend: {
                        title: {
                            text: 'City<br/><span style="font-size: 9px; color: #666; font-weight: normal">(Total: ' + total + ')</span>' 
                        }
                    }
                })
              };
于 2017-03-31T14:58:08.783 回答