I'm using a simple Highcharts column chart to display a single series set of data. an array that's external to Highcharts is being used to generate a tooltip for each column when hovered over. There is a column for each month of the year. Everything works great when using the 'Highcharts.each' function within the tooltip pointFormatter. Each monthly column displays the proper stock tickers for that particular month: for instance when hovering over the "January" chart column, the tooltip displays "January" on the top line and "CMA, OMC, DIS, JPM," on the next line within the tooltip. Note: the last 6 months of the year are still in the future at this point so that's why the last 6 elements in the 'tooltip_ticks' array have empty values.
var tooltip_ticks =
[["CMA","OMC","DIS","JPM"],
["TXN","ABBV","SPG"],
["ENB","TJX","TGT","MMM","MSFT","VBR","ED","HD","AVGO","VTV"],
["CMA","OMC","FXAIX","JPM"],
["CVS","ABBV","TXN"],
["ENB","WFC","PFE","TGT","MSFT","MMM","ED","HD"],
"","","","","",""]
.
.
.
tooltip: {
useHTML: true,
pointFormatter: function() {
var string = '';
Highcharts.each(tooltip_ticks[this.series.data.indexOf(this)], function(tick) {
string += tick + ', '
});
return string;
}
}
the Highcharts.each function has been deprecated. I have spent nearly 2 hours and multiple code iterations trying to figure out how to replicate the code above using the js Array.forEach function. One example:
pointFormatter: function() {
var string = '';
tooltip_ticks.forEach(function(tick) {
string += tick + ', '
});
return string;
}
This creates a tooltip for each month, but each monthly tooltip includes ALL the elements in the 'tooltip_ticks' array. I can't figure out how to get the proper monthly sub-array index so that just the singular month's worth of tickers is displayed in each tooltip. In other words, the equivalent of this
tooltip_ticks[this.series.data.indexOf(this)]
Do I need to do some sort of 'For' loop inside the forEach function because the sub-arrays need to be looped over and the sub-array elements extracted one by one?
I would classify my experience level using js and/or Highcharts charting library as 'beginner', so not exactly novice but still in the early learning mode. any help/advice would be greatly appreciated.
