0
votes

From http://s831.us/ySLjng

I am developing my own custom Axis Formatter. I would like the yAxis and Point labels to render values differently depending on the type of data being displayed (e.g. volume, percentage, US dollars, British Pound, etc.)

It is not possible to determine the type of data from just the single value or point. The context of the type of data is set on the series or chart. It is not set once statically. I retrieve different data sets dynamically using based on users inputs (e.g. financial instrument symbol .DJI, AAPL, BP.L, etc.).

I have not found a way to access the series or chart context from the Axis or Tooltip formatter. I have also not been able to find a way to reset the formatter in the Ajax "success" handler.

Any suggestions?

UPDATE: The original question asked about context for both the Axis and Tooltip Formatter.The Tooltip formatter does get the series via this.series. I haven't found an analogues context in the Axis Formatter.

1
According to the docs for the Tooltip formatter (highcharts.com/ref/#tooltip--formatter), the series object is this.series, the chart would be this.series.chart then.Mark
Yes, I have found that the Tooltip formatter does get the series. But I don't see a similar capability with the Axis formatter.Steve Wilhelm

1 Answers

3
votes

It's not part of an official release yet, but I just added axis and chart to this-context in the axis formatters, so the following is now possible:

yAxis: {        
    labels: {
        formatter: function() {
            console.log(this.axis); // Current Axis instance
            console.log(this.chart); // The Chart instance
            return this.value +' - ' + this.chart.options.chart.renderTo;
        }
    }
}

Example on jsfiddle

Link to the latest development version of HighCharts