高脚椅如何将HTML添加到图例中

时间:2015-02-15 04:29:03

标签: highcharts

我正在使用highcharts,我想在自动生成的图例中添加一些html。

legend: {
    useHTML: true,
    labelFormatter: function(){
        return '<div>Div that I want to prepend</div>';
     }
}

以上代码将替换不附加的图例。

任何人都可以告诉我如何在传奇之前加上它而不是覆盖它吗?

2 个答案:

答案 0 :(得分:1)

var chart = new Highcharts.Chart({.......});

$(chart.legend.group.div).find('span').append('<div>Div that I want to prepend</div>');

答案 1 :(得分:0)

labelFormatter: function () {
      return this.name + '<div>Div that I want to prepend</div>';
}