Change Highcharts tooltip formatter from chart Object , after chart is rendered

后端 未结 1 2081
醉话见心
醉话见心 2021-02-19 21:07

I have found that I can change series with setData, and I know I can modify Max values with .setExtremes , but I cannot figure out how to set the tooltip formatter from the char

相关标签:
1条回答
  • 2021-02-19 21:43

    You can use chart.tooltip.options.formatter instead, like

    chart.tooltip.options.formatter = function() {
        var xyArr=[];
        $.each(this.points,function(){
            xyArr.push('Serie: ' + this.series.name + ', ' +'X: ' + this.x + ', Y: ' +this.y);
        });
        return xyArr.join('<br/>');
    }
    

    Changing tooltip formatter dynamically | Highchart & Highstock @ jsFiddle

    UPDATE In new (5.0.0+) versions of highcharts, this can also be done using the chart.update() method

      chart.update({
        tooltip: {
          formatter: function() {
            var xyArr = [];
            $.each(this.points, function() {
              xyArr.push('Serie: ' + this.series.name + ', ' + 'X: ' + this.x + ', Y: ' + this.y);
            });
            return xyArr.join('<br/>');
          }
        }
      });
    

    Changing tooltip formatter dynamically with chart.update | Highchart & Highstock @ jsFiddle

    0 讨论(0)
提交回复
热议问题