customization - highcharts customize tooltip for a single point -
i want customize tooltip of last point in specific series, leave other points in series, , other series, default tooltip format. basically, looking similar config. in advance help!
series: [{ tooltip: { // ?? tooltip not work inside series formatter: function() { if (lastpoint in series) { // ?? how determine if lastpoint return '<b>final result </b> ' + this.y; } // ?? return default format if not last point in series } }, data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6] }, { data: [194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2] }]
the formatter function doesn't seem work when it's defined series. can check series in using this.series.name , can check if on final point using this.series.xdata.length - 1 == this.point.x. but, easier name point want target , check in formatter function. http://jsfiddle.net/swsbb/. see formatter data, check here http://api.highcharts.com/highcharts#tooltip.formatter.
$('#container').highcharts({ xaxis: { categories: ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul'] }, tooltip : { formatter: function() { var tooltip; if (this.key == 'last') { tooltip = '<b>final result </b> ' + this.y; } else { tooltip = '<span style="color:' + this.series.color + '">' + this.series.name + '</span>: <b>' + this.y + '</b><br/>'; } return tooltip; } }, series: [{ data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, {y:135.6, name: 'last'}] }, { data: [194.1, 95.6, 54.4, 29.9, 71.5, 106.4, 129.2] }] });
Comments
Post a Comment