What are formatted labels?

Formatted labels were added to RGraph as of version 6.0 and allow you to specify a template for your labels and RGraph will do the job of adding the correct values into the correct places by way of the macros that are available to you. The information on this page applies to both canvas and SVG charts.

[No canvas support]

Formatted labels are available to you as of version 6.0 of RGraph for both canvas and SVG charts and allow you to specify a single template string as the label which has certain macros in it and RGraph will replace those macros with the correct values.

Label templates are very similar to tooltip templates in their appearance albeit with fewer macros available to them (because only strings are permitted - not HTML).

Here's an example of a canvas chart that uses label templates. In the download archive there's a demo called demos/activity-radial2.html which shows off label templates to good effect. It's not by any means a complicated demo - but it's effective.

    data   = [28,19,39,45];
    values = RGraph.clone(data);
    labels = ['John','Fred','Mark','Andy'];
    new RGraph.Activity({
        id: 'cvs',
        min: 0,
        max: 100,
        value: data,
        options: {
            marginInner: 3,
            backgroundColor: 'transparent',
            backgroundGrid: false,
            backgroundGridRadials: false,
            backgroundRings: false,
            colors: ['red','blue','#aaa','black'],
            labels: '%{global:labels[%{index}]} (%{value_formatted})',
            labelsFormattedUnitsPost: '%',
            labelsSize: 16,
            labelsBold: true,
            labelsItalic: true,
            labelsColor: '#333',
            labelsOffsetx: -20,
            adjustable: true,

What macros are available?

You can use these macros when you're creating your template label string. Note that because there's no concept of a group or sequential index there's only one index macro available.