Highcharts: To bold last total value of stacked column -


i been trying bold last total value of stacked column. needed.

thanks in advance!

it keep asking me write more keep asking me write more keep asking me write more keep asking me write more keep asking me write more keep asking me write more

http://jsfiddle.net/leslie20/ekylqz47/

$(function () {           highcharts.setoptions({             global: {               vmlradialgradienturl: 'http://code.highcharts.com/{version}/gfx/vml-radial-gradient.png',  // path pattern image required vml browsers in order draw radial gradients.               canvastoolsurl: 'http://code.highcharts.com/{version}/modules/canvas-tools.js'            // url additional file lazy load android 2.x devices. these devices don't support svg, download helper file contains canvg, dependecy rbcolor, , our own canvg renderer class.             },             title: {                 align: 'left',                 style : { color: '#f7921e',fontsize: '14px', fontweight: 'bold'}             },             plotoptions: {                 series: {                     grouppadding: 0.1,                     pointwidth: 28,                     padding: 2                 }             },             xaxis: {                 tickcolor: 'null',                 linecolor: '#4d4d4f',                 labels: {                     formatter: function () {                         if (this.islast) {                             return '<span style="font-weight: bolder; font-size: 12px">' + this.value + '</span>';                         }                          else {                            return this.value;                         }                     }                 }             },             legend: {                 itemstyle: {                     fontweight: 'normal'                 }             },             credits: {enabled: false},             lang: {               loading: 'loading...', // loading text appears when chart set loading state                thousandssep: ','  // default thousands separator used in highcharts.numberformat method unless otherwise specified in function arguments.             }             // tooltip: {enabled: false}           });  $('#container6').highcharts({             chart: { type: 'column' },             title: { text: 'cash distribution per share (declared)'},              xaxis: {                 categories: [                     '2010',                     '2011',                     '2012',                     '2013',                     '2014'                 ]             },             legend: {                 reversed: true,             },              yaxis: {                 min: 0,                 gridlinecolor: '#ffffff',                 title: {text: ''},                 labels: { enabled: false },                 stacklabels: {                      enabled: true,                     y: -3,                     formatter: function() {                         return  highcharts.numberformat(this.total, 1);                     },                      style: {                         fontweight: 'normal'                     }                 }             },             plotoptions: {                  column: {                     stacking: 'normal',                      datalabels: {                         enabled: true,                         format: '{point.y:,.1f}',                         style: {                           textshadow: false,                        }                     }                  }             },             series: [{                 name: 'special dividend<br>(cents)',                 tooltip: {                     pointformat: 'special dividend: <b>{point.y:,.1f} cents</b>'                 },                 color: '#414042',                 data: [3.5, null, 1.7, 7.1, null],                 datalabels: {                     enabled: true,                     style: {                         fontweight: 'normal'                     },                     formatter: function() {                         if (this.y != 0) {                           return this.y;                         } else {                           return null;                         }                     }                 }              }, {                 name: 'final dividend<br>(cents)',                 tooltip: {                     pointformat: 'final dividend: <b>{point.y:,.1f} cents</b>'                 },                 color: '#f7921e',                 datalabels: {                     enabled: true,                     style: {                         fontweight: 'normal'                      },                 },                 data: [7.7, 7.9, 6.3, 7.1, {                     datalabels: {                         enabled: true,                         style: {                             fontweight: 'bolder',                             fontsize: '12px'                         },                     },                     y: 11.9                 }],                }, {                 name: 'interim dividend<br>(cents)',                 tooltip: {                     pointformat: 'interim dividend: <b>{point.y:,.1f} cents</b>'                 },                 color: '#939598',                 datalabels: {                     enabled: true,                     style: {                         fontweight: 'normal'                     },                 },                 data: [6.3, 6.6, 6.6, 6.8, {                     datalabels: {                         enabled: true,                         style: {                             fontweight: 'bolder',                             fontsize: '12px'                         },                     },                     y: 7.0                 }],              }]         });       }); 

thanks in advance!

you can use stacklabels formatter , check last tick on xaxis compared current x of stacklabel. if same, bold that.

formatter: function () {                 var ticks = this.axis.chart.xaxis[0].tickpositions,                     len = ticks.length,                     last = ticks[len - 1];                  if(this.x === last)                      return '<span style="font-weight:bold">' + highcharts.numberformat(this.total, 1) + '</span>';                 else                     return highcharts.numberformat(this.total, 1);             }, 

example: http://jsfiddle.net/ekylqz47/2/


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -