How to use the tooltip formatter and still display chart color (like it does by default)?

前端 未结 4 1174
野趣味
野趣味 2020-12-24 05:26

If I\'m using the default Highcharts tooltip, it displays a circle the color of the chart data (the light/dark blue circles at http://jsfiddle.net/WOUNDEDStevenJones/mpMvk/1

4条回答
  •  半阙折子戏
    2020-12-24 06:25

    I found the documentation for this (http://api.highcharts.com/highcharts#tooltip.pointFormat). The HTML they're using is located under pointFormat, not formatter:

    \u25CF {series.name}: {point.y}

    Here's the updated code to use to get the colored circles in the tooltip:

    tooltip: {
        formatter: function() {
            var s = ''+ this.x +'';
    
            $.each(this.points, function(i, point) {
                s += '
    \u25CF ' + point.series.name + ': ' + point.y; }); return s; }, shared: true },

提交回复
热议问题