SVG Semi-circular Progress charts API reference

Share RGraph:   To help my Google visibility (it can't get much worse!), if you like and use RGraph I'd appreciate it if you could link to me

Summary
Documentation about the SVG Semi-circular Progress chart including information on all the options and methods that are available to you.

 

Example

The code below produces a chart like this:

<script>
    new RGraph.SVG.SemiCircularProgress({
        id: 'chart-container',
        min: 0,
        max: 10,
        value: 7.8,
        options: {
            labelsCenterDecimals: 1
        }
    }).draw();
</script>

 

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.

Layout style:     
  

Chart configuration

PropertyDescriptionDefault
centerxIf required, you can position the progress bar using this instead of the gutters.null
centeryIf required, you can position the progress bar using this instead of the gutters.null
radiusIf required, you can size the progress bar using this instead of the gutters.null
widthThe width of the progress bar (ie the outer radius minus the inner radius).60

Margins

PropertyDescriptionDefault
gutterLeftThe left gutter of the chart, (the gutter is where the labels and title are)).35
gutterRightThe right gutter of the chart, (the gutter is where the labels and title are).35
gutterTopThe top gutter of the chart, (the gutter is where the labels and title are).35
gutterBottomThe bottom gutter of the chart, (the gutter is where the labels and title are).35

Background

PropertyDescriptionDefault
backgroundStrokeLinewidthThe linewidth of the outline that goes around the background.0.25
backgroundStrokeThe color of the background fill.gray
backgroundFillThe color of the background fill.Gradient(white:#aaa)
backgroundFillOpacityThe opacity of the background fill color.0.25

Colors

PropertyDescriptionDefault
colorsThe color to be used for the progress bar.['#0c0']
strokestyleThe color of the outline of the progress bar.#666

Labels and text

PropertyDescriptionDefault
textFontThe font used to render the text.sans-serif
textSizeThe size of the text.10
textColorThe color of the labels.black
textItalicWhether the labels are italic or not.false
textBoldWhether the labels are bold or not.false
unitsPreUnits that are pre-pended to the label(s).(An empty string)
unitsPostUnits that are appended to the label(s).(An empty string)
scalePointThe default character used as the decimal point.
scaleThousandThe default character used as the thousand seperator,
scaleDecimalsThe default number of decimals to apply to the labels0
scaleFormatterA function used as the formatter. This function should look like this:
scaleFormatter: function (obj, num)
{
}
null
labelsMinWhether to show the minimum label.true
labelsMinFontThe font used to render the minimum label.null
labelsMinSizeThe size of the minimum label.null
labelsMinColorThe color of the minimum label.null
labelsMinItalicWhether the minimum label is italic or not.null
labelsMinBoldWhether the minimum label is bold or not.null
labelsMinUnitsPreUnits that are pre-pended to the minimum label.null
labelsMinUnitsPostUnits that are appended to the minimum label.null
labelsMinPointThe character used as the decimal point for the minimum label.null
labelsMinThousandThe character used as the thousand seperator for the minimum label.null
labelsMinDecimalsThe number of decimals to apply to the minimum label.null
labelsMinSpecificThe specific text to use as the minimum label.null
labelsMinFormatterA function used as the formatter for the minimum label. This function should look like this:
labelsMinFormatter: function (obj, num)
{
}
null
labelsMaxWhether to show the maximum label.true
labelsMaxFontThe font used to render the maximum label.null
labelsMaxSizeThe size of the maximum label.null
labelsMaxColorThe color of the maximum label.null
labelsMaxItalicWhether the maximum label is italic or not.null
labelsMaxBoldWhether the maximum label is bold or not.null
labelsMaxUnitsPreUnits that are pre-pended to the maximum label.null
labelsMaxUnitsPostUnits that are appended to the maximum label.null
labelsMaxPointThe character used as the decimal point for the maximum label.null
labelsMaxThousandThe character used as the thousand seperator for the maximum label.null
labelsMaxDecimalsThe number of decimals to apply to the maximum label.null
labelsMaxSpecificThe specific text to use as the maximum label.null
labelsMaxFormatterA function used as the formatter for the maximum label. This function should look like this:
labelsMaxFormatter: function (obj, num)
{
}
null
labelsCenterWhether to show the center label.true
labelsCenterFontThe font used to render the center label.null
labelsCenterSizeThe size of the center label.40
labelsCenterColorThe color of the center label.#666
labelsCenterItalicWhether the center label is italic or not.null
labelsCenterBoldWhether the center label is bold or not.true
labelsCenterUnitsPreUnits that are pre-pended to the center label.null
labelsCenterUnitsPostUnits that are appended to the center label.null
labelsCenterPointThe character used as the decimal point for the center label.null
labelsCenterThousandThe character used as the thousand seperator for the center label.null
labelsCenterDecimalsThe number of decimals to apply to the center label.null
labelsCenterSpecificThe specific text to use as the center label.null
labelsCenterFormatterA function used as the formatter for the center label. This function should look like this:
labelsCenterFormatter: function (obj, num)
{
}
null

Title

PropertyDescriptionDefault
titleThe title of the chart.(An empty string)
titleXThe specific X coordinate of the title.null
titleYThe specific Y coordinate of the title.null
titleHalignThe horizontal alignment of the title.center
titleValignThe vertical alignment of the title.bottom
titleColorThe color of the title. It defaults to be the same as the textColor property.null
titleFontThe font used to render the title.null
titleSizeThe size of the font used to render the title. It defaults to be a little larger than the textSize propertynull
titleBoldWhether the title is bold or not.false
titleItalicWhether the title is italic or not.false
titleSubtitleThe subtitle of the chart. If a subtitle is specified the title is moved up to accommodate it. As such you might need to give a larger gutterTop value.(An empty string)
titleSubtitleXThe specific X coordinate of the subtitle.null
titleSubtitleYThe specific Y coordinate of the subtitle.null
titleSubtitleHalignThe horizontal alignment of the subtitle.center
titleSubtitleValignThe vertical alignment of the subtitle.top
titleSubtitleColorThe color of the subtitle.#aaa
titleSubtitleFontThe font used to render the subtitle.null
titleSubtitleSizeThe size of the font used to render the subtitle. It defaults to be the same as the textSize setting.null
titleSubtitleBoldWhether the subtitle is bold or not.false
titleSubtitleItalicWhether the subtitle is italic or not.false

Tooltips

PropertyDescriptionDefault
tooltipsAn array of tooltips for the chart. This array should NOT be multidimensional - even for stacked or grouped charts.null
tooltipsOverrideIf required, this can be a function that totally handles the tooltip showing instead of the default RGraph tooltips. It should look like this:
tooltipsOverride: function (obj, opt)
{
    // Show tooltip
}
The opt is an argument that contains these items:
  • object The chart object.
  • index The index of the element (that triggered the tooltip).
  • sequentialIndex The sequential index of the element that was clicked.
  • text The text to be used as the tooltip. Remember that this may contain HTML (or whatever else you may have specified).
  • event The event object (either a click or mousemove event).
null
tooltipsCssClassThe CSS class thats applied to the tooltip DIV.RGraph_tooltip
tooltipsEventThe event used for tooltips (either click or mousemove.click

Highlight

PropertyDescriptionDefault
highlightStrokeThe color of the stroke of the highlight.rgba(0,0,0,0)
highlightFillThe color of the fill of the highlight.rgba(255,255,255,0.7)
highlightLinewidthThe linewidth of the stroke of the highlight.1

Other

PropertyDescriptionDefault
linewidthThe linewidth of the seperating lines.0

Methods

 

obj.set(name, value)

This can be used to set properties if necessary. It's normally used after the chart is drawn if you need to set additional parameters or change them.

 

obj.on(event, handler)

This function adds an event listener (such as onbeforedraw or ondraw) to the chart object.

 

obj.exec(func)

This function simply executes the function that you give it (there and then - not on any particular event)

 

Animation Effects

These effects are available and can be used instead of the .draw() function.
<script>
    /**
    * Optional callback function that's called when the effect is complete
    */
    function myCallback (obj)
    {
        // ...
    }

    new RGraph.SVG.SemiCircularProgress({
        id: 'chart-container',
        min: 0,
        max: 100,
        value: 84.99,
        options: {
            colors: ['Gradient(#faa:pink)'],
            labelsCenterUnitsPre: '$',
            labelsCenterDecimals: 2
        }
    }).grow({frames: 60, callback: myCallback});
</script>