This project is read-only.

Accessing chart data through an event

May 27, 2014 at 11:02 AM
Hi, I am fairly new to highcharts and very weak on javascript but I have some working charts and would like to access chart data through a click event to pass the category from the selected bar to a linq query. I have copied the example given for Pie chart events but don't seem to be able to access the values of x or y in the same way that you can on a tool tip. Can someone help.

.SetPlotOptions(new PlotOptions
                {
                    Bar = new PlotOptionsBar
                    {
                        DataLabels = new PlotOptionsBarDataLabels
                        {
                            Enabled = true,
                            Style = "color: '#FFF', font: '16px Lucida Grande, Lucida Sans Unicode, Verdana, Arial, Helvetica, sans-serif'"
                        },
                        Events = new PlotOptionsBarEvents
                        {
                            Click = "function(event) { alert('The bar '+this.x+' was clicked!'); }" 
                        }
                    }

                })
The above returns "Undefined" for this.x

Martin
May 27, 2014 at 4:58 PM
I have gone back to the Highcharts API reference (http://api.highcharts.com/highcharts#chart.events.click) and the functionality I am looking for doesn't seem to exist with a click event. I will find another solution.
Marked as answer by Vangi on 6/3/2014 at 1:17 AM