Array variable to option data loop array and update


« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by eric on 1st August 2015
Hi RGrapher

I am trying with no success to update option data dynamically see example
var json ="['A','B','C','D','E','F','G','H','I','J']";

  options: {
    labels: json,
tooltips: function (index)
{
   var label = bar8.Get('labels')[index];
   return '<div style="text-align: center; font-weight: bold; font-size: 16pt">' + label + '</div><br /><canvas id="tooltip_canvas" width="250" height="110"></canvas>';
  }
}

What i am trying to do is to update label from string values

Thks
Posted by Richard on 1st August 2015
Hi,

Because what you're assigning to your json variable has quotes around it is therefore a string - it just happens to look a little like an array. So you could try this:

var labels =['A','B','C','D','E','F','G','H','I','J'];

options: {
   labels: labels,
   tooltips: function (index)
   {
     var label = bar8.Get('labels')[index];
    
     return '<div style="text-align: center; font-weight: bold; font-size: 16pt">' + label + '</div><br /><canvas id="tooltip_canvas" width="250" height="110"></canvas>';
}
}

Richard

Add a reply

 




« Back to message list
RGraph on social media