RGraph: HTML5 canvas graph library - Meter documentation

This is the Meter chart. Similar to half the Odometer. The difference is purely visual, but may well be more suited to a control panel type application.

The example file is here.

<script>
    window.onload = function ()
    {
        var meter = new RGraph.Meter('myCanvas', 50, 100, 60);
        meter.Set('chart.contextmenu', [
                                        ['Show palette', RGraph.Showpalette],
                                        ['Clear annotations', function () {RGraph.Clear(meter.canvas); meter.Draw();}],
                                        null,
                                        ['Cancel', function () {}]
                                       ]);
        meter.Set('chart.annotatable', true);
        meter.Set('chart.label.position', 'inside');
        meter.Set('chart.title', 'A sample measurement');
        meter.Set('chart.title.vpos', 0.5);
        meter.Set('chart.units.post', 'k');
        meter.Set('chart.red.start', 0);
        meter.Set('chart.red.end', 3);
        meterSet('chart.yellow.start', 3);
        meter.Set('chart.yellow.end', 6);
        meter.Set('chart.green.start', 6);
        meter.Set('chart.green.end', 10);
        meter.Draw();
    }
</script>

Available properties

You can use these properties to control how the Meter apears. You can set them by using the Set() method. Eg:

myMeter.Set('name', 'value');

chart.gutter The gutter of the graph.
Default: 25
chart.linewidth The width of the outline of the Meter.
Default: 2
chart.border.color The color of the outline (including tickmarks).
Default: black
chart.green.start The value that the green area should begin at.
Default: 35% of the maximum value
chart.green.end The value that the green area should end at.
Default: The maximum value
chart.green.color The color of the green area, (can be any color)..
Default: #207A20
chart.yellow.start The value that the yellow area should begin at.
Default: 10% of the maximum value
chart.yellow.end The value that the yellow area should end at.
Default: 35% of the maximum value
chart.green.color The color of the yellow area, (can be any color)..
Default: #D0AC41
chart.red.start The value that the red area should begin at.
Default: The minimum value
chart.red.end The value that the red area should end at.
Default: 10% of the maximum value
chart.red.color The color of the red area, (can be any color)..
Default: #9E1E1E
chart.text.color The color of the labels.
Default: black
chart.text.size The size (in points) of the labels.
Default: 10
chart.text.font The font used to render the text.
Default: Verdana
chart.title The title of the graph, if any.
Default: null
chart.title.color The color of the title.
Default: black
chart.title.vpos This allows you to completely override the vertical positioning of the title. It should be a number between 0 and 1, and is multiplied with the gutter and then used as the vertical position. It can be useful if you need to have a large gutter.
Default: null
chart.contextmenu An array of context menu items. More information on context menus is here.
Default: [] (An empty array)
chart.units.pre The units that the labels are measured in. This string is displayed BEFORE the actual number, allowing you to specify values such as "$50".
Default: none
chart.units.post The units that the labels are measured in. This string is displayed AFTER the actual number, allowing you to specify values such as "50ms".
Default: none
chart.labels.position This determines whether the labels for the chart are drawn either on the inside or the outside of the meter. Possible values are inside or outside.
Default: outside
chart.annotatable Whether annotations are enabled for the chart (ie you can draw on the chart interactively).
Default: false
chart.annotate.color If you do not allow the use of the palette, then this will be the only color allowed for annotations.
Default: black
chart.zoom.mode Can be used to control whether the zoom is in thumbnail or canvas mode. Possible values are: thumbnail and canvas.
Default: canvas
chart.zoom.factor This is the factor that the graph will be zoomed by (bigger values means more zoom)
Default: 1.5
chart.zoom.fade.in Whether the zoomed canvas fades in or not. This also can be used to control the fade in for the zoom in thumbnail mode.
Default: true
chart.zoom.fade.out Whether the zoomed canvas fades out or not. This also can be used to control the fade in for the zoom in thumbnail mode.
Default: true
chart.zoom.hdir The horizontal direction of the zoom. Possible values are: left, center, right
Default: right
chart.zoom.vdir The vertical direction of the zoom. Possible values are: up, center, down
Default: down
chart.zoom.delay The delay (in milliseconds) between frames.
Default: 50
chart.zoom.frames The number of frames in the zoom animation.
Default: 10
chart.zoom.shadow Whether or not the zoomed canvas has a shadow or not.
Default: true
chart.zoom.thumbnail.width When the zoom is in thumbnail mode, this is the width (in pixels) of the thumbnail.
Default: 75
chart.zoom.thumbnail.height When the zoom is in thumbnail mode, this is the height (in pixels) of the thumbnail.
Default: 75