Vertical Progress bar API reference

Summary: Documentation about the Vertical Progress bar including information about all of the options that are available to you. The Vertical Progress bar can be used to show one or more values or quantities. The standard Bar chart can also be configured to look like a progress bar.

Example

<script>
    new RGraph.VProgress({
        id: 'cvs',
        min: 0,
        max: 100,
        value: 78,
        options: {
            colors: ['Gradient(white:red)'],
            marginRight: 50,
            marginInner: 15
        }
    }).draw();
</script>

Properties

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

Margin properties

PropertyDescriptionDefault
marginLeftThe left margin of the chart).25
marginRightThe right margin of the chart.25
marginTopThe top margin of the chart.25
marginBottomThe bottom margin of the chart.25
marginInnerThe inner margin of the progress bar.0
marginLeft
The left margin of the chart).
Default: 25

marginRight
The right margin of the chart.
Default: 25

marginTop
The top margin of the chart.
Default: 25

marginBottom
The bottom margin of the chart.
Default: 25

marginInner
The inner margin of the progress bar.
Default: 0

Background properties

PropertyDescriptionDefault
backgroundColorThe background color.#eee
backgroundColor
The background color.
Default: #eee

Color properties

PropertyDescriptionDefault
colorsThe color of the bar. This can be a solid color, or a gradient that you create.[#0c0]
colorsStrokeInnerThis is the stroke color used for the inner part of the chart.#999
colorsStrokeOuterThis is the stroke color used for the outer part of the chart.#999
colors
The color of the bar. This can be a solid color, or a gradient that you create.
Default: [#0c0]

colorsStrokeInner
This is the stroke color used for the inner part of the chart.
Default: #999

colorsStrokeOuter
This is the stroke color used for the outer part of the chart.
Default: #999

Tickmark properties

PropertyDescriptionDefault
tickmarksOuterCountHow many outer tickmarks there are.0
tickmarksInnerCountHow many inner tickmarks there are.0
tickmarksOuterCount
How many outer tickmarks there are.
Default: 0

tickmarksInnerCount
How many inner tickmarks there are.
Default: 0

Shadow properties

PropertyDescriptionDefault
shadowWhether a drop shadow is applied.false
shadowColorThe color of the shadow.rgba(0,0,0,0.5)
shadowOffsetxThe X offset of the shadow.3
shadowOffsetyThe Y offset of the shadow.3
shadowBlurThe severity of the shadow blurring effect.3
shadow
Whether a drop shadow is applied.
Default: false

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

shadowOffsetx
The X offset of the shadow.
Default: 3

shadowOffsety
The Y offset of the shadow.
Default: 3

shadowBlur
The severity of the shadow blurring effect.
Default: 3

Labels and text properties

PropertyDescriptionDefault
textAccessibleA new feature in 2016 that allows you to use DOM text in place of canvas text. It makes for much higher quality text that you can also select if desired (for copy/paste operations). It won't fit all situations and you can read more about the DOM text feature here. A good way to control borders/margins/padding etc is not to set them on the canvas but to wrap the canvas in a div and set them on that like this:
<div style="margin-left: 50px; display: inline-block">
<canvas id="cvs" width="650" height="250"></canvas>
</div>
true
textAccessibleOverflowThis can be visible or hidden and it controls whether the text is clipped to the edges of the canvas. It defaults to be visible and means you can set small margins if you wish.visible
textAccessiblePointereventsThis controls whether the DOM text responds to mouse based events or not (it sets the pointer-events CSS property to none).true
textFontThe font used to render the text.Arial, Verdana, sans-serif
textColorThe color of the labels.black
textSizeThe size of the text (in points).12
textBoldWhether the text on the chart is bold or not.false
textItalicWhether the text on the chart is bold or not.false
labelsFontThe font used to render the labels.null
labelsColorThe color of the labels.null
labelsSizeThe size of the labels (in points).null
labelsBoldWhether the labels on the chart are bold or not.null
labelsItalicWhether the labels on the chart are italic or not.null
labelsInnerWhether a label is displayed just above the progress bar.false
labelsInnerFontThe font used for the inner label.null
labelsInnerSizeThe size of the inner label.null
labelsInnerColorThe color of the inner label.null
labelsInnerBoldWhether the inner labels is bold or not.null
labelsInnerItalicWhether the inner labels is italic or not.null
labelsInnerBackgroundFillThe background color of the inner label.rgba(255,255,255,0.75)
labelsInnerBorderWhether the background label has a border or not.true
labelsInnerBorderLinewidthThe linewidth of the border of the label.1
labelsInnerBorderColorThe color of the border of the label.#ccc
labelsInnerDecimalsHow many decimals the inner labels have.0
labelsInnerUnitsPreUnits which are prepended to the label.(an empty string)
labelsInnerUnitsPostUnits which are appended to the label.(an empty string)
labelsInnerPointThe character that is used as the decimal separator..
labelsInnerThousandThe character that is used as the thousand separator.,
labelsInnerSpecificThis can be a specific label that you want to show instead of the value.null
labelsPositionCan be left or right and controls which side the labels are positioned on.right
labelsSpecificIf you want to specify your own labels, which can be textual, you can use this.null
labelsCountThis controls how many labels there are.10
labelsOffsetxThis can be used to move the labels in the X direction.0
labelsOffsetyThis can be used to move the labels in the Y direction.0
textAccessible
A new feature in 2016 that allows you to use DOM text in place of canvas text. It makes for much higher quality text that you can also select if desired (for copy/paste operations). It won't fit all situations and you can read more about the DOM text feature here. A good way to control borders/margins/padding etc is not to set them on the canvas but to wrap the canvas in a div and set them on that like this:
<div style="margin-left: 50px; display: inline-block">
<canvas id="cvs" width="650" height="250"></canvas>
</div>

Default: true

textAccessibleOverflow
This can be visible or hidden and it controls whether the text is clipped to the edges of the canvas. It defaults to be visible and means you can set small margins if you wish.
Default: visible

textAccessiblePointerevents
This controls whether the DOM text responds to mouse based events or not (it sets the pointer-events CSS property to none).
Default: true

textFont
The font used to render the text.
Default: Arial, Verdana, sans-serif

textColor
The color of the labels.
Default: black

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

textBold
Whether the text on the chart is bold or not.
Default: false

textItalic
Whether the text on the chart is bold or not.
Default: false

labelsFont
The font used to render the labels.
Default: null

labelsColor
The color of the labels.
Default: null

labelsSize
The size of the labels (in points).
Default: null

labelsBold
Whether the labels on the chart are bold or not.
Default: null

labelsItalic
Whether the labels on the chart are italic or not.
Default: null

labelsInner
Whether a label is displayed just above the progress bar.
Default: false

labelsInnerFont
The font used for the inner label.
Default: null

labelsInnerSize
The size of the inner label.
Default: null

labelsInnerColor
The color of the inner label.
Default: null

labelsInnerBold
Whether the inner labels is bold or not.
Default: null

labelsInnerItalic
Whether the inner labels is italic or not.
Default: null

labelsInnerBackgroundFill
The background color of the inner label.
Default: rgba(255,255,255,0.75)

labelsInnerBorder
Whether the background label has a border or not.
Default: true

labelsInnerBorderLinewidth
The linewidth of the border of the label.
Default: 1

labelsInnerBorderColor
The color of the border of the label.
Default: #ccc

labelsInnerDecimals
How many decimals the inner labels have.
Default: 0

labelsInnerUnitsPre
Units which are prepended to the label.
Default: (an empty string)

labelsInnerUnitsPost
Units which are appended to the label.
Default: (an empty string)

labelsInnerPoint
The character that is used as the decimal separator.
Default: .

labelsInnerThousand
The character that is used as the thousand separator.
Default: ,

labelsInnerSpecific
This can be a specific label that you want to show instead of the value.
Default: null

labelsPosition
Can be left or right and controls which side the labels are positioned on.
Default: right

labelsSpecific
If you want to specify your own labels, which can be textual, you can use this.
Default: null

labelsCount
This controls how many labels there are.
Default: 10

labelsOffsetx
This can be used to move the labels in the X direction.
Default: 0

labelsOffsety
This can be used to move the labels in the Y direction.
Default: 0

Scale properties

PropertyDescriptionDefault
scaleUnitsPreThe units that the Y scale is measured in (these are prepended to the number).none
scaleUnitsPostThe units that the Y scale is measured in (these are appended to the number).none
scaleDecimalsThis stipulates how many decimal places there are.0
scalePointThe character used as the decimal point..
scaleThousandThe character used as the thousand separator.,
scaleUnitsPre
The units that the Y scale is measured in (these are prepended to the number).
Default: none

scaleUnitsPost
The units that the Y scale is measured in (these are appended to the number).
Default: none

scaleDecimals
This stipulates how many decimal places there are.
Default: 0

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

scaleThousand
The character used as the thousand separator.
Default: ,

Title properties

PropertyDescriptionDefault
titleThe title of the progress bar.An empty string
titleFontThe font that the title is rendered in.null
titleSizeThe size of the title.null
titleBoldWhether the title is bold or not.null
titleItalicWhether the title is italic or not.null
titleColorThe color of the title.null
titleSideUsing this property you can specify a title for the chart that is displayed in the left hand margin (vertically).null
titleSideFontThe font used to draw the side title.null
titleSideSizeThe font size of the side title.null
titleSideColorThe color used for the side title.null
titleSideBoldWhether the side title is bold or not.null
titleSideItalicWhether the side title is italic or not.null
title
The title of the progress bar.
Default: An empty string

titleFont
The font that the title is rendered in.
Default: null

titleSize
The size of the title.
Default: null

titleBold
Whether the title is bold or not.
Default: null

titleItalic
Whether the title is italic or not.
Default: null

titleColor
The color of the title.
Default: null

titleSide
Using this property you can specify a title for the chart that is displayed in the left hand margin (vertically).
Default: null

titleSideFont
The font used to draw the side title.
Default: null

titleSideSize
The font size of the side title.
Default: null

titleSideColor
The color used for the side title.
Default: null

titleSideBold
Whether the side title is bold or not.
Default: null

titleSideItalic
Whether the side title is italic or not.
Default: null

Interactive features properties

PropertyDescriptionDefault
tooltipsAn array, albeit one element only. This is shown when the progress bar is clicked on. Tooltips can contain HTML.An empty array
tooltipsEffectThe effect used for showing tooltips. Can be either fade or none.fade
tooltipsCssClassThis is the name of the CSS class the chart uses.RGraph_tooltip
tooltipsOverrideIf you wish to handle showing tooltips yourself, this should be a function object which does just that. There's more information on the tooltips documentation page.null
tooltipsNohideonclearNot an option that you'll need particularly often if at all. Setting this to true means that when you call the RGraph.clear() API function tooltips do not get hidden.false
contextmenuAn array of context menu items. More information about context menus is here.[] (An empty array)
annotatableWhether annotations are enabled for the chart (ie you can draw on the chart interactively.false
annotatableColorIf you do not allow the use of the palette, then this will be the only color allowed for annotations.black
annotatableLinewidthThis is the linewidth of the annotations.1
adjustableDefaulting to false, this determines whether your bar chart will be adjustable.false
tooltips
An array, albeit one element only. This is shown when the progress bar is clicked on. Tooltips can contain HTML.
Default: An empty array

tooltipsEffect
The effect used for showing tooltips. Can be either fade or none.
Default: fade

tooltipsCssClass
This is the name of the CSS class the chart uses.
Default: RGraph_tooltip

tooltipsOverride
If you wish to handle showing tooltips yourself, this should be a function object which does just that. There's more information on the tooltips documentation page.
Default: null

tooltipsNohideonclear
Not an option that you'll need particularly often if at all. Setting this to true means that when you call the RGraph.clear() API function tooltips do not get hidden.
Default: false

contextmenu
An array of context menu items. More information about 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

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

annotatableLinewidth
This is the linewidth of the annotations.
Default: 1

adjustable
Defaulting to false, this determines whether your bar chart will be adjustable.
Default: false

Key properties

The key properties are documented on the key documentation page.

Miscellaneous properties

PropertyDescriptionDefault
highlightStyleBy default this is null but you can set it to a function if you wish so that function is called to do the chart highlighting. It's passed the shape object as an argument.null
highlightStrokeIf you use tooltips, this controls the color of the highlight stroke.black
highlightFillIf you use tooltips, this controls the color of the highlight fill.rgba(255,255,255,0.5)
cleartoThis is used in animations and effects as the default color to use when clearing the canvas.null
highlightStyle
By default this is null but you can set it to a function if you wish so that function is called to do the chart highlighting. It's passed the shape object as an argument.
Default: null

highlightStroke
If you use tooltips, this controls the color of the highlight stroke.
Default: black

highlightFill
If you use tooltips, this controls the color of the highlight fill.
Default: rgba(255,255,255,0.5)

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

Methods

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

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

obj.getShape(event)
This method makes it easy to get hold of the bar when it's been clicked on or hovered over. It returns an object which has the following indexes available:
object The chart object.
x The X coordinate of the progress bar.
y The Y coordinate of the progress bar.
width The width of the progress bar.
height The height of the progress bar.
dataset As there's only ever one dataset on the progress bar this is always zero.
index This is the index of the element that's been clicked or hovered over . If your progress bar only has one value then this will always be zero - it's only really used in a stacked bar.
sequentialIndex Because there's only one bar (or set of bars on a stacked chart) this value is always the same as the index value.
tooltip If a tooltip is associated with the segment this will be it.id: strings are expanded for you (where the tooltip text is retrieved from the HTML tag with the matching ID).
<script>
    vprogress.canvas.onclick = function (e)
    {
        RGraph.redraw();
    
        var canvas = e.target,
            obj    = canvas.__object__,
            shape  = obj.getShape(e);

        if (shape) {            
            // Highlight the progress bar.
            RGraph.path({
                object: obj,
                  path: 'lw 10 b r % % % % s black f red',
                  args: [shape.x, shape.y, shape.width, shape.height]
            });
        }
    }
</script>

obj.getValue(mixed)

This method can be used to get the value at a particular point or at the mouse coordinates, based on the scale that is in use. Not simply the coordinates of the mouse. The argument can either be an event object (for use in event listener functions) OR a two element array consisting of the X and Y coordinates (ie when you're not necessarily in an event listener). It returns null if the mouse or coordinates are in the margin areas. An example:

progress.canvas.onclick = function (e)
{
    var obj   = e.target.__object__;
    var value = obj.getValue(e);
    
    // ...
}

obj.getYCoord(value)

This method can be used to retrieve the correct Y coordinate for the given Y value.

<script>
    coord = progress.getYCoord(27);
</script>

obj.on(event, function)

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 that you wish to attach to and the second is the handler function. For example:

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

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

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

obj.exec(function)

The exec function is documented here.


Custom RGraph events that are available

Custom RGraph events are events that RGraph fires when certain actions occur. There is a more comprehensive list of these events here . Here's some example code that show you how to add these events to your chart.

There's more documentation about events available here: Summary of events documentation

<script>
    vprogress = new RGraph.VProgress({
        id: 'cvs',
        min: 0,
        max: 100,
        value: 65,
        options: {
        }
    }).draw().on('click', function (e, shape)
    {
        // Add your click event listener code here

    }).on('mousemove', function (e, shape)
    {
        // Add your mousemove event listener code here

    }).on('mouseover', function (e, shape)
    {
        // Add your mouseover event listener code here

    }).on('mouseout', function (obj)
    {
        // Add your mouseout event listener code here
    });
</script>

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>
    /**
    * Optional callback function that's called when the effect is complete
    */
    function myCallback (obj)
    {
        // ...
    }

    var obj = new RGraph.VProgress({
        id: 'cvs',
        min: 0,
        max: 100,
        value: 56,
        options: {
            marginLeft: 35
        }
    }).grow({frames: 60}, myCallback);
</script>