Bookmark and share:
Bookmark with delicious tweet this site

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>

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');

Margins

chart.gutter
The gutter of the graph.
Default: 25

Colors

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

Labels and text

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

Titles

chart.title
The title of the graph, if any.
Default: null

chart.title.background
The background color (if any) for the title.
Default: null

chart.title.color
The color of the title.
Default: black

chart.title.hpos
This allows you to completely override the horizontal positioning of the title. It should be a number between 0 and 1, and is multiplied with the whole width of the canvas and then used as the horizontal position.
Default: null

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

Scale

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

Interactive features

chart.contextmenu
An array of context menu items. More information on context menus is here.
Default: [] (An empty array)

chart.resizable
Defaulting to false, this determines whether your graph will be resizable. Because of the numerous event handlers this has to install code on, This feature is unlikely to work with other dynamic features (the context menu is fine however).
Default: false

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

Shadow

chart.shadow
If true a shadow will be applied to the meter.
Default: false

chart.shadow.color
The color of the shadow.
Default: rgba(0,0,0,0.5)

chart.shadow.offsetx
The X offset in pixels for the shadow.
Default: 3

chart.shadow.offsety
The Y offset in pixels for the shadow.
Default: 3

chart.shadow.blur
The severity of the shadow blurring effect.
Default: 3

Zoom

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

chart.zoom.background
Defaulting to true, this determines whether the zoom has a dark, semi-opaque background that covers the entire web page.
Default: true

Miscellaneous

chart.linewidth
The width of the outline of the Meter.
Default: 2