RGraph is a JavaScript charts library based on HTML5 SVG and canvas. RGraph is mature (over 15 years old) and has a wealth of features making it an ideal choice to show charts on your website.

More »


Get the latest version of RGraph (version 6.17) from the download page. There's also older versions available, minified files and links to cdnjs.com hosted libraries.

More »


RGraph can be used for free under the GPL or if that doesn't suit your situation there's an inexpensive (£129) commercial license available.

More »

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

Posted by giuseppe at 13:29 on Wednesday 23rd March 2022 [link]
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:


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


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


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


There are demos of Line chart clipping in the download:


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]