I need to modify this to show the percentage of the x series of data. For this example the total percentage would be for the 2 x points of data in the column. For example column "Jun" Customer Owned would be 90% and Supplier Owned would be 10% (totaling 100%). Is this possible to do with this same code? I tried switching point.y to point.x and this.y to this.x but that doesn't work and returns NaN%
wojtek wrote:Hi russelln,
To find the percentage of each point in tooltip:
1. Count all series data values on chart load event and add it to the series object:
}Code: Select all
chart: { events: { load: function() { var chart = this; chart.series.forEach(function(series) { series.pointsSum = 0; series.data.forEach(function(point) { series.pointsSum += point.y; }); }); } }
2. Use tooltip.formatter function to count percentage for each series point:
Api reference: https://api.highcharts.com/highcharts/tooltip.formatterCode: Select all
tooltip: { formatter: function() { var percentage = ((this.y / this.series.pointsSum) * 100).toFixed(2); return percentage + '%'; } }
Online demo: http://jsfiddle.net/wchmiel/57Ldakh0/
Best regards.