Adding different colors to different edges

Share RGraph:   Share or Like RGraph on Facebook!

« 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 Vamsi on 28th February 2014
Hi,

I need to customise my graph in such a way that all active edges should be in green color and inactive edges should be in red color.

please help me in implementing this
Posted by Richard on 28th February 2014
Hi there,

Edges? Do you mean the outline/stroke color? If so you will need to use the ondraw event and then in that do the custom highlighting. Use the coordinates that RGraph gives you. For example:

bar.ondraw = function (obj)
{
     var x = obj.coords[0][0]; // First bar, X coordinate
     var y = obj.coords[0][1]; // First bar, Y coordinate
     var w = obj.coords[0][2]; // First bar, width
     var h = obj.coords[0][3]; // First bar, height

     obj.context.strokeStyle = 'green';
     obj.context.lineWidth = 3;
     obj.context.strokeRect(x, y, w, h);
}

You can change the strokestyle to red/green as you see fit. The ondraw event is used to perform highlighting.


Richard

Add a reply




« Back to message list