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.20
Version 7.20 (released in June 2026) is the latest version of RGraph and the major change in this version is an update to the default values of properties making for better looking charts without having to set any properties. Read more about this and other changes in the changelog.

Download »

 

Download
Get the latest version of RGraph (version 7.20, 9th June 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 »

 

Latest forum posts
These are the latest support forum posts that have been posted or updated.


16th June, Rachel
I have a question about the 3D Bar chart
12th June, Marco
Should I use SVG or canvas for the charts on my website?
9th June, Richard
New version of RGraph: version 7.20
3rd June, Patrick
Question about installing RGraph
1st June, Ouja
How do I add a click event to a bar in my Bar chart?


Support forum »

 

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]