AndyKL
AndyKL

Reputation: 21

HighCharts: get Y and X value

I created a "basic line" chart with Highcharts, which has round 15 series or graphs.

If I use "plotOptions" to try to show Y and X value, I only get one series of values (Y OR X). It's depend on the line point: within I get Y, without I get only X.

plotOptions: {
    series: {
        cursor: 'pointer',
        point: {
            events: {
                click: function () {
                    //OpenDetails(this.category, this.y);
                    alert('Value1:'+this.category + ', Value2: ' +
                          this.y + ', Value:' + this.name);
                }
            }
        }
    }
}

I found a help here, but it's only for 1 series of values (X or Y): http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-events-click/

Maybe the solution is to build in plotOptions into the series, but I I did't manage it.

Upvotes: 0

Views: 1159

Answers (1)

ppotaczek
ppotaczek

Reputation: 39099

You should use series.point.events, not series.events:

plotOptions: {
    series: {
        cursor: 'pointer',
        point: {
            events: {
                click: function(event) {
                    alert('Value1:' + this.category + ', Value2: ' +
                           this.y + ', Value:' + this.series.name)
                }
            }
        }
    }
}

Live demo: http://jsfiddle.net/BlackLabel/eb9y1noj/

API: https://api.highcharts.com/highcharts/plotOptions.series.point.events.click

Upvotes: 1

Related Questions