SVG line chart: Is it possible to add an option to set the key background color?

Post a reply

Posted by Anthony Kuma at 00:58 on Monday 16th November 2026 [link]
Howdy Richard,
any chance of getting a key background color property for SVG line chart.
I tend to run a darkmode page and the key white background harasses my eyes.
Regards,
Anthony Kuma

Posted by Richard at 13:13 on Monday 16th November 2026 [link]
Hi Anthony,

I was beginning to wonder if forum posting was still working!

Yes, I'll look at that later on this afternoon.

Cheers.

Richard

Posted by Richard at 14:46 on Monday 16th November 2026 [link]
Hi Anthony,

Ok I've looked into it and it might be already implemented - just not documented. So try setting this configuration property to transparent - that way the background color (which I'm assuming that you have set to black) will show through:

keyLabelsBackground: 'transparent'

Here's an example chart:

<script>
    new RGraph.SVG.Line({
        id: 'cc',
        data: [4,8,5,5,5],
        options: {
            spline: true,
            linewidth: 3,
            tickmarksStyle: 'filledcircle',
            colors: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850"],
            tooltips: [
                '1960','1970','9180','1990','2000',
                '1960','1970','9180','1990','2000',
                '1960','1970','9180','1990','2000',
                '1960','1970','9180','1990','2000',
                '1960','1970','9180','1990','2000'
            ],
            xaxisLabels: ['1960','1970','1980','1990','2000'],
            key: ["Africa", "Asia", "Europe", "Latin America", "North America"],
            keyTextSize:12,
            keyLabelsBackground: '#0000',
            xaxisColor: '#aaa',
            yaxisColor: '#aaa',
            yaxisLabelsCount: 10,
            yaxisScaleUnitsPost: 'k',
            marginLeft: 45,
            textSize: 9,
            textColor: '#aaa',
            textSize: 16,
            backgroundGridColor: '#666'
        }
    }).draw().on('beforetooltip', function ()
    {
        RGraph.SVG.tooltips.style.backgroundColor = 'white';
        RGraph.SVG.tooltips.style.color         = 'black';
        RGraph.SVG.tooltips.style.fontWeight     = 'bold';
    });
</script>

Richard

Post a reply

What's your name?
What do you want to say?