How to add text via chart.renderer.text in Highcharts? -


i have succeeded adding additional text charts, here. this, achieved through adding "function(chart)" "var chart = new highcharts.chart"

$.get('xxx.csv', function(data) {     var chart = new highcharts.chart({                   ...         plotoptions:          {             series:              {                 ....             }         }     }, function(chart)     {         chart.renderer.text('the dotted line represents ...', 100, 86)             .css({                 fontsize: '13px',                 color: '#666666'             })             .add();     } )}; 

my current format different:

$(function () {      var options =      {         chart:          {             ...         },         ...     };      $.get('xxx.csv', function(data)     {            var series = {             data: []         };          var temp = []          // split lines         var lines = data.split('\n');          // each line, split record seperate attributes         $.each(lines, function(lineno, line) {             var items = line.split(',');              if (lineno !== 0) {                 var xvalue = +items[0],                     kwh = parsefloat(items[2] / 1000);                 if (!isnan(kwh)) {                     series.data.push({x:xvalue,y: kwh, extra:items[1]});                 }             }         });           // push completed series         options.series.push(series);          new highcharts.chart(options);     }); }); 

now, wonder how can add chart.renderer.text graph. have tried different things, didn't succeed. , how supposed add code text now? here fiddle this. hints!

you can add text inside load event callback function of chart. can add function inside options - options.chart.events object. http://api.highcharts.com/highcharts#chart.events.load

options.chart.events = {   load: function() {     var chart = this;     chart.renderer.text('the dotted line represents ...', 100, 186)       .css({         fontsize: '13px',         color: '#666666'       })       .add();   } } 

here can see example how can work: http://jsfiddle.net/17ed42pa/1/

best regards.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -