MENU
.net Powerful JavaScript charts
About
RGraph is a JavaScript charts library based on HTML5 SVG and canvas. RGraph is mature (over 18 years old) and has a wealth of features making it an ideal choice to use for showing charts on your website.

More »

 

Version 7.11
Version 7.11 (released in March 2026) is the latest version of RGraph and contains just a few updates to the code which you can see on the changelog page. There's a new dumbbell variation for the Bar and Horizontal bar charts (both SVG and canvas) and the front page layout of the website has been tweaked.

Download »

 

HTML datagrid
In the April 2025 (v6.21) release a new datagrid object was added. This makes it easy to add static or dynamic data tables to your pages. It can be used whether you use the canvas or SVG libraries or entirely standalone.

Read more »

 

Download
Get the latest version of RGraph (version 7.11, 21st March 2026) from the download page. You can read the changelog here. There's also older versions available, minified files and links to cdnjs.com hosted libraries.

Download »

 

License
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 we customize the label color or font based on the value?


Posted by Ananth at 15:51 on Thursday 20th October 2022 [link]
can we customize datalable color or font based on Number?

e.g., if we have 0 (Zero) color will be white and for greater than 0 it will be on black etc?


new RGraph.Bar({
    id: 'cvs2dr',
    data: [1, 0, 8, 4, 6, 3, 1, 5, 7, 8, 4, 6],
    data: dRej,
    options: {
        xaxisLabels: dR,
        labelsAbove: true,
        title: 'DRR',
        xaxisTickmarksCount: 0,
        xaxisLinewidth: 3,
        yaxis: false,
        colors: ['#FF0000', '#54A4CF'],
        backgroundGridVlines: false,
        backgroundGridHlines: false,
        backgroundGridBorder: false,
        titleSize: 12,
        tooltipsPointer: false,
        tooltipsPositionStatic: false,
        tooltipsCss: {
            fontSize: '10pt',
            border: '5px solid #666',
            textAlign: 'left',
            pointerEvents: 'none',
        },
        tooltipsEffect: 'none',
        tooltipsEvent: 'mousemove'
    },
}).draw().responsive([
    { maxWidth: null, width: 600, height: 250, options: { textSize: 8 }, parentCss: { 'float': 'right' } },
    { maxWidth: 800, width: 350, height: 200, options: { textSize: 12 }, parentCss: { 'float': 'none', textAlign: 'center' } }
]);

Posted by Richard at 16:50 on Thursday 20th October 2022 [link]
I was all ready to say "That would be rather involved" and then I realised that you're probably referring to the X-axis labels - not the Y axis labels. This makes it somewhat easier.

There's still nothing built-in that will do what you want, but what you can do, is use the draw event to have some custom code run to draw the labels yourself and this way you can determine the color based on the data.

I've made you a demo here:

https://codepen.io/rgraph/full/yLjdqBo

If you want to omit the label though you could just not draw it at all or set the color to transparent, Otherwise I'd choose a different color.

[Replies are closed]