Is there zindex control on a canvas?

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 Rob Blackin on 19th December 2015
I have a canvas with a scatter chart with line:true. Then after the canvas is drawn, I use Path to draw an area and fill it with opaqueness 0.5 so you can see through it.

What I want to do is have the lines of the series not appear to be below the filled area. Id like to have the series in the chart be above the area and not change color in the area.

Is there a way to do it? I dont see anything like a zindex or anything talking about how to control what object is above another object in a canvas.

thanks,

Rob
Posted by Richard on 19th December 2015
Hi,

I'm afraid not. What you can do instead though is use the beforedraw RGraph event like this:


var scatter = new RGraph.Scatter({
     id: 'cvs',
     data: [...],
     options: {
         // Options...
     }
}).on('beforedraw', function (obj)
{
     // Draw the rectangle here
}).draw();


Keep in mind though that when the Scatter runs the beforedraw function none of the coordinates will exist yet - so you won't be able to use them.




Richard
Posted by Rob Blackin on 19th December 2015
Thanks for responding.

hmm, unfortunately that wont work for me. I need the coordinates. I'm using scatter.coords[] to trace the lines.

Any other options? Maybe two canvases on top of each other? Is that possible?
Posted by Richard on 19th December 2015
Hi,

You do the draw first:

var scatter = new RGraph.Scatter({
      id: 'cvs',
      data: [...],
      options: {
          // Options...
      }
}).draw().on('beforedraw', function (obj)
{
     // Draw the rectangle here;
     alert(In the beforedraw function);
});

And then call the redraw function:

RGraph.redraw();

When the chart is redrawn - and thus the newly installed beforedraw event handler runs - the coords should be available but the chart will be drawn on top of whatever you draw on there.

It should be quick enough for you not to see a flash.




Richard
Posted by Rob Blackin on 20th December 2015
thank you very much, worked perfectly.

Rob

Add a reply




« Back to message list