Odometer charts documentation


Important note! The options green.solid, yellow.solid and red.solid have all been retired. By default the green/yellow/red colors are all solid. Gradients can still be applied but by using the new easy gradient syntax: obj.set('green.color', 'Gradient(white:green)');

 

Example

<script>
    $(document).ready(function ()
    {
        var odo = new RGraph.Odometer({
            id: 'cvs',
            min: 0,
            max: 100,
            value: 18,
            options: {
                greenMax: 75,
                redMin: 90,
                labelArea: 50,
                needleThickness: 2
            }
        }).draw();
    });
</script>

The example file is here.

 

Properties

You can use these properties to control how the chart apears. You can set them by including them in the options section of the configuration as above.

 

Chart configuration

border
This controls the gray border of the Odometer.
Default: false

tickmarks
This controls whether tickmarks are shown. If you're animating the Odometer you'll need to turn this off.
Default: true

tickmarksHighlighted
This controls whether the tickmarks are highlighted in red/yellow/green.
Default: false

zerostart
If you want the top value on your chart to be zero instead of the maximum value, set this to true.
Default: false

centerx
If required, you can position the Meter chart using this instead of the gutters.
Default: null

centery
If required, you can position the Meter chart using this instead of the gutters.
Default: null

radius
If required, you can size the Meter chart using this instead of the gutters.
Default: null

 

Margins

gutterLeft
The left gutter of the chart, (the gutter is where the labels and title are)).
Default: 25

gutterRight
The right gutter of the chart, (the gutter is where the labels and title are).
Default: 25

gutterTop
The top gutter of the chart, (the gutter is where the labels and title are).
Default: 25

gutterBottom
The bottom gutter of the chart, (the gutter is where the labels and title are).
Default: 25

 

Colors

borderColor1
This is the first color used in the gradient of the outer border of the chart (if enabled).
Default: #BEBCB0

borderColor2
This is the second/middle color used in the gradient of the outer border of the chart (if enabled).
Default: #F0EFEA

borderColor3
This is the third color used in the gradient of the outer border of the chart (if enabled).
Default: #BEBCB0

greenMax
This is the point at which the green area ends.
Default: 75% of the maximum value

redMin
This is the point at which the red area starts. The yellow area is between the green and red areas.
Default: 90% of the maximum value

greenColor
This is the color of the green area.
Default: green

yellowColor
This.the color of the yellow area.
Default: yellow

redColor
This.the color of the red area.
Default: red

 

Labels and text

valueText
Controls whether the value is indicated as a text label in the center of the dial.
Default: false

valueUnitsPre
The pre units used on the textual value.
Default: An empty string

valueUnitsPost
The post units used on the textual value.
Default: An empty string

labels
Instead of using computed numbers, which uses the maximum value, you can specify the Odometer to use textual labels instead, with this option.
Default: null

labelArea
The width of the area that labels are put in.
Default: 35

textSize
The size of the text (in points).
Default: 10

textFont
The font used to render the text.
Default: Arial

textColor
The color of the labels.
Default: black

 

Needle

needleWidth
How thick the needle is.
Default: 2

needleColor
The color that is applied to the needle.
Default: black

needleHead
This controls whether the arrow head on the end of the needle is displayed.
Default: true

needleType
This determines which type of needle is used. It can be pointer or triangle.
Default: pointer

needleTriangleBorder
This controls the colour of the border for the pointer. If you don't want it you could set it to be transparent - rgba(0,0,0,0).
Default: #aaa

needleExtra
With this you can specify a number of extra pointers that will be drawn on the Odometer. An example would be a meter that's used to show upload and download data. An example use:
odo.set('needle.extra', [[16, 'red'], [24, 'blue']]);

Default: An empty array

 

Titles

title
The title text.
Default: null

titleFont
The font that the title is rendered in. If not specified the text.font setting is used (usually Arial)
Default: null

titleSize
The size of the title. If not specified the size is usually 2pt bigger than the text.size setting.
Default: null

titleBold
Whather the title is bold or not.
Default: true

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

titleColor
The color of the title.
Default: black

titleX
To give the exact X coordinate for the title - use this
Default: null

titleY
To give the exact Y coordinate for the title - use this
Default: null

 

Shadow

shadowInner
Whether a drop shadow is applied to the inner circle of the Odometer
Default: false

shadowInnerColor
The color for the inner shadow.
Default: black

shadowInnerOffsetx
The X offset for the inner shadow.
Default: 3

shadowInnerOffsety
The Y offset for the inner shadow.
Default: 3

shadowInnerBlur
The extent of the blurring effect on the shadow.
Default: 6

shadowOuter
Whether a drop shadow is applied to the whole Odometer.
Default: false

shadowOuterColor
The color for the outer shadow.
Default: black

shadowOuterOffsetx
The X offset for the outer shadow.
Default: 3

shadowOuterOffsety
The Y offset for the outer shadow.
Default: 3

shadowOuterBlur
The extent of the blurring effect on the shadow.
Default: 6

 

Interactive features

contextmenu
An array of context menu items. More information on context menus is here.
Default: An empty array

annotatable
Whether annotations are enabled for the chart (ie you can draw on the chart interactively.
Default: false

annotateColor
If you do not allow the use of the palette, then this will be the only colour allowed for annotations.
Default: black

annotateLinewidth
This is the line width of the annotations.
Default: 1

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

resizeHandleBackground
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

adjustable
You can make the Odometer interactively adjustable by setting this to true.
Default: false

 

Zoom

zoomFactor
This is the factor that the chart will be zoomed by (bigger values means more zoom)
Default: 1.5

zoomFadeIn
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

zoomFadeOut
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

zoomHdir
The horizontal direction of the zoom. Possible values are: left, center, right
Default: right

zoomVdir
The vertical direction of the zoom. Possible values are: up, center, down
Default: down

zoomDelay
The delay (in milliseconds) between frames.
Default: 50

zoomFrames
The number of frames in the zoom animation.
Default: 10

zoomShadow
Whether or not the zoomed canvas has a shadow or not.
Default: true

 

Scale

unitsPre
The units that the value is measured in. This string is displayed BEFORE the actual number, allowing you to specify values such as "$50" and is only used if value.text is true.
Default: none

unitsPost
The units that the value is measured in. This string is displayed AFTER the actual number, allowing you to specify values such as "50ms" and is only used if value.text is true.
Default: none

scaleDecimals
The number of decimal places to display for the labels.
Default: 0

scalePoint
The character used as the decimal point.
Default: .

scaleThousand
The character used as the thousand separator
Default: ,

 

Miscellaneous

clearto
This is used in animations and effects as the default color to use when the canvas.
Default: null

 

Methods

 

obj.get(name)
An accessor that you can use to retrieve the value of properties.

 

obj.set(name, value)
An accessor that you can use to set the value of properties.

 

obj.getAngle(value)
This method will return you an appropriate angle for the given value.

 

obj.on(event, func)

This method can be used to set an event listener on an object. It operates in a similar way to the jQuery .on() function - the first argument is the event you wish to attach to and the second is the handler function. For example:

.on('draw', function (obj)
{
    // Put event code here
});

The function is useful if you use method chaining when creating your charts:

var obj = new RGraph.Odometer({
    id: 'cvs',
    min: 0,
    max: 100,
    value: 56
}).on('draw', function (e, shape)
{
    // Put ondraw code here
})
.on('click', function (e, shape)
{
    // Handle click event
}).draw();

 

Animation Effects

These effects are available and can be used instead of the .draw() function. There are also generic effects available which you can see here: Generic effects and transitions
<script>
    $(document).ready(function ()
    {
        /**
        * Optional callback function that's called when the effect is complete
        */
        function myCallback (obj)
        {
            // ...
        }
    
        var obj = new RGraph.Odometer({
            id: 'cvs',
            min: 0,
            max: 100,
            value: 56,
            options: {
                gutterLeft: 35
            }
        }).grow({frames: 60}, myCallback);
    });
</script>