Highlight a bar without an event

Share RGraph:  

« 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 Nathan Lipke on 23rd October 2013
Hi, I'm getting an event from an external source and would like to highlight the corresponding bar in a stacked bar graph.

I have it working, but would like to make sure I did it correctly:
var bar = new RGraph.HBar(....);

function onMyEvent(x, y) {
        coords = bar.coords2[x][y]
        bar.Highlight({x : coords[0], y : coords[1], width : coords[2], height : coords[3]});
}


Also, official support of getting a shape from it's x,y or sequential index would be helpful.

Thanks
Posted by RGraph Support on 23rd October 2013
Hi there,

Looks fine - kudos on managing to decipher the code! The RGraph.Highlight.Rect() function in the common.core library is what does the actual highlighting - though I'd imagine that you've found that already.

If you wanted to you could use the coordinates that you have with the canvas API fillRect() function directly - though you'd also need to use the canvas API to set color information so if what you have works - I'd stick with it.

To get a "shape" - which really is just a set of coordinates with a few extra bits (eg index) - you can access the .coords or .coords2 array (the obj.coords array is sequential whilst the obj.coords2 array is grouped by dataset). Or if you're in an event handler you can use the obj.getShape(e) function.




Richard, RGraph Support



   

Add a reply




« Back to message list