javascript - getting highcharts point id based on data from json -
i'm using highcharts renders barchart data provided json, works fine. i'm trying is, each bar displayed on chart, clicking on must navigate page , data displayed on navigated page should based on id of clicked bar on barchart. not sure how go doing have far.
var values: array<any> = []; var labels: array<any> = []; var ids: array<any> = []; this.service.getdata(url).subscribe( data => { this.results = data; this.results.map(function(result){ values.push(result.percentage); labels.push(result.displayname); ids.push(result.id); }) this.chart = { title: { text: '', style: { display: 'none' } }, credits: { enabled: false }, chart: { type: 'bar', marginleft: 120 }, xaxis: { categories: labels, }, yaxis: { min: 0, max: 100, title: { text: '', style: { display: 'none' } }, labels: { overflow: 'justify' } }, tooltip: { valuesuffix: ' %' }, plotoptions: { bar: { datalabels: { enabled: false } }, series: { pointwidth: 15, cursor: 'pointer', point: { events: { click: function(){ } } } } }, series: [{ showinlegend: false, data: values, name: 'demo' }] }; } );
add highcharts plotoption click event barchart looks
plotoptions: { ... ... events: { click: function (event) { //event handling code } } } },
the idea that, onclicking bar, window has navigate yourr second page receives information using get
or post
see highcharts plotoptions api , highcharts jsfiddle demo more
Comments
Post a Comment