RGraph: HTML5 Javascript charts library - Meter charts documentation
These are Meter charts. 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.left
The left gutter of the chart, (the gutter is where the labels and title are)).
Default: 25
chart.gutter.right
The right gutter of the chart, (the gutter is where the labels and title are).
Default: 25
chart.gutter.top
The top gutter of the chart, (the gutter is where the labels and title are).
Default: 25
chart.gutter.bottom
The bottom gutter of the chart, (the gutter is where the labels and title are).
Default: 25
Colors
chart.strokestyle
The color of the bits separating the segements. By setting this to white you can get a separation effect.
Default: null
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
chart.value.text
This option controls whether the value of the Meter is shown in text.
Default: false
chart.value.text.decimals
The amount of decimals shown in the text label.
Default: 0
chart.value.text.units.pre
The units (before the value) shown in the text label.
Default: None (an empty string)
chart.value.text.units.post
The units (after the value) shown in the text label.
Default: None (an empty string)
chart.labels
Whether the labels are shown or not.
Default: true
Titles
chart.title
The title of the chart, if any.
Default: null
chart.title.font
The font that the title is rendered in. If not specified the chart.text.font setting is used (usually Verdana)
Default: null
chart.title.size
The size of the title. If not specified the size is usually 2pt bigger than the chart.text.size setting.
Default: null
chart.title.bold
Whather the title is bold or not.
Default: true
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
chart.scale.decimals
The number of decimal places to display for the values.
Default: 0
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 chart 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.resize.handle.background
With this you can specify the background color for the resize handle. If you're adjusting the position of the
handle then you may need this to make the handle stand out more.
Default: null
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 chart 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
chart.linewidth.segments
The linewidth of the lines separating the segments.
Default: 1
chart.tickmarks.small.num
This controls the number of small tickmarks.
Default: 100
chart.tickmarks.big.num
This controls the number of large tickmarks.
Default: 10
chart.tickmarks.small.color
This sets the color of the small tickmarks.
Default: #bbb
chart.tickmarks.big.color
This sets the color of the large tickmarks.
Default: black
chart.border
Whether the outline is drawn.
Default: true
chart.segment.radius.start
Instead of the segments going from the center point outwards, you can use this to specify a start point of the
coloured segments.
Default: null
chart.needle.radius
This can be used to stipulate the radius of the pointer.
Default: null
chart.needle.linewidth
This can be used to specify the linewidth used when drawing the needle.
Default: null
chart.needle.tail
If true the needle will have a small tail.
Default: false