Can I show three (or more) colors on my Line chart? - Official support forum | RGraph.net

Can I show three (or more) colors on my Line chart?


Posted by giuseppe at 13:29 on Wednesday 23rd March 2022 [link]
hi
I'm using successfully RGraph.line.js and related libraries.
I made a dual-color line graph but now i'd need to add a color, so graph should be a three colors.
Is it possible or exist a new better way ?
many thanks

Posted by Richard at 18:12 on Wednesday 23rd March 2022 [link]
You can. You can do it in two ways that I can think of:

1. Use gradients. There are two demo pages in the download archive that show this:
    i. line-filled-striped.html
ii. line-banded-gradient.html

2. Use clipping. This is a little more involved and involves drawing a path (a rectangle in your case by the sounds of it) to which any further drawing is restricted.

So you set the clipping, draw the first chart, reset the clipping.

Set new clipping (to the second section), change the colors on the chart and then draw it again, then reset the clipping.

And finally set new clipping to the third section, change the colors again and draw the chart. Then reset the clipping.

This, as you can see, is more involved but it is a bit more versatile.

I'm actually in the middle of creating an RGraph.clipTo.start() function which will make this much easier - so if you hold on a few days I'll send you an updated RGraph.common.core.js file so you can use it.

Posted by Richard at 20:58 on Thursday 24th March 2022 [link]
Ok, try having a look at this example:

[LINK REMOVED]

To use this sort of chart on your own website you'll need to use this version of the core library:

[LINK REMOVED]

And you can get the source of the example page by viewing the source in your browser.

UPDATE

This is now part of version 6.07 and you can read about the RGraph.clipTo functions in the API documentation:

https://www.rgraph.net/canvas/api.html#functions.clipping

There are demos of Line chart clipping in the download:

https://www.rgraph.net/download.html#stable

And they're called line-clippingX.html

Posted by giuseppe at 21:03 on Monday 28th March 2022 [link]
well ... i'll try in these days
many many thanks

[Replies are now closed]