SVG Semi-circular Progress bar API reference

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

 

Example

The code below produces a chart like this:

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

    //scp.nodes.labelsCenter.onclick = function (e)
    //{
    //    alert('The value is: ' + scp.value);
    //}
    //
    //scp.nodes.labelsCenter.onmousemove = function (e)
    //{
    //    e.target.style.cursor = 'pointer';
    //}
</script>

 

The obj.nodes property

Instead of coordinates the Semi-circular Progress maintains references to the nodes that are created - such as the bar, the background and text nodes. For example:

You could, for example, add your own event listeners like this:

<script>
    obj.nodes.labelsCenter.onclick = function (e)
    {
        alert('The value is: ' + scp.value);
    }

    obj.nodes.labelsCenter.onmousemove = function (e)
    {
        e.target.style.cursor = 'pointer';
    }
</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 is shown above.

Chart configuration properties

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

centery
If required, you can position the progress bar using this instead of the margins.
Default: null

radius
If required, you can size the progress bar using this instead of the margins.
Default: null

width
The width of the progress bar (ie the outer radius minus the inner radius).
Default: 60

Margin properties

PropertyDescriptionDefault
marginLeftThe left margin of the chart, (the margin is where the labels and title are)).35
marginRightThe right margin of the chart, (the margin is where the labels and title are).35
marginTopThe top margin of the chart, (the margin is where the labels and title are).35
marginBottomThe bottom margin of the chart, (the margin is where the labels and title are).35
marginLeft
The left margin of the chart, (the margin is where the labels and title are)).
Default: 35

marginRight
The right margin of the chart, (the margin is where the labels and title are).
Default: 35

marginTop
The top margin of the chart, (the margin is where the labels and title are).
Default: 35

marginBottom
The bottom margin of the chart, (the margin is where the labels and title are).
Default: 35

Background properties

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
backgroundStrokeLinewidth
The lineWidth of the outline that goes around the background.
Default: 0.25

backgroundStroke
The color of the background fill.
Default: gray

backgroundFill
The color of the background fill.
Default: Gradient(white:#aaa)

backgroundFillOpacity
The opacity of the background fill color.
Default: 0.25

Color properties

PropertyDescriptionDefault
colorsThe color to be used for the progress bar.['#0c0']
colorsStrokeThe color of the outline of the progress bar.#666
colors
The color to be used for the progress bar.
Default: ['#0c0']

colorsStroke
The color of the outline of the progress bar.
Default: #666

Labels and text properties

PropertyDescriptionDefault
textFontThe font used to render the text.Arial, Verdana, sans-serif
textSizeThe size of the text.12
textColorThe color of the labels.black
textItalicWhether the labels are italic or not.false
textBoldWhether the labels are bold or not.false
scaleUnitsPreUnits that are pre-pended to the label(s).(An empty string)
scaleUnitsPostUnits 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 separator.,
scaleDecimalsThe default number of decimals to apply to the labels.0
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 separator 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 separator 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.null
labelsCenterItalicWhether the center label is italic or not.null
labelsCenterBoldWhether the center label is bold or not.null
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 separator 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
textFont
The font used to render the text.
Default: Arial, Verdana, sans-serif

textSize
The size of the text.
Default: 12

textColor
The color of the labels.
Default: black

textItalic
Whether the labels are italic or not.
Default: false

textBold
Whether the labels are bold or not.
Default: false

scaleUnitsPre
Units that are pre-pended to the label(s).
Default: (An empty string)

scaleUnitsPost
Units that are appended to the label(s).
Default: (An empty string)

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

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

scaleDecimals
The default number of decimals to apply to the labels.
Default: 0

scaleFormatter
A function used as the formatter. This function should look like this:
scaleFormatter: function (obj, num)
{
}

Default: null

labelsMin
Whether to show the minimum label.
Default: true

labelsMinFont
The font used to render the minimum label.
Default: null

labelsMinSize
The size of the minimum label.
Default: null

labelsMinColor
The color of the minimum label.
Default: null

labelsMinItalic
Whether the minimum label is italic or not.
Default: null

labelsMinBold
Whether the minimum label is bold or not.
Default: null

labelsMinUnitsPre
Units that are pre-pended to the minimum label.
Default: null

labelsMinUnitsPost
Units that are appended to the minimum label.
Default: null

labelsMinPoint
The character used as the decimal point for the minimum label.
Default: null

labelsMinThousand
The character used as the thousand separator for the minimum label.
Default: null

labelsMinDecimals
The number of decimals to apply to the minimum label.
Default: null

labelsMinSpecific
The specific text to use as the minimum label.
Default: null

labelsMinFormatter
A function used as the formatter for the minimum label. This function should look like this:
labelsMinFormatter: function (obj, num)
{
}

Default: null

labelsMax
Whether to show the maximum label.
Default: true

labelsMaxFont
The font used to render the maximum label.
Default: null

labelsMaxSize
The size of the maximum label.
Default: null

labelsMaxColor
The color of the maximum label.
Default: null

labelsMaxItalic
Whether the maximum label is italic or not.
Default: null

labelsMaxBold
Whether the maximum label is bold or not.
Default: null

labelsMaxUnitsPre
Units that are pre-pended to the maximum label.
Default: null

labelsMaxUnitsPost
Units that are appended to the maximum label.
Default: null

labelsMaxPoint
The character used as the decimal point for the maximum label.
Default: null

labelsMaxThousand
The character used as the thousand separator for the maximum label.
Default: null

labelsMaxDecimals
The number of decimals to apply to the maximum label.
Default: null

labelsMaxSpecific
The specific text to use as the maximum label.
Default: null

labelsMaxFormatter
A function used as the formatter for the maximum label. This function should look like this:
labelsMaxFormatter: function (obj, num)
{
}

Default: null

labelsCenter
Whether to show the center label.
Default: true

labelsCenterFont
The font used to render the center label.
Default: null

labelsCenterSize
The size of the center label.
Default: 40

labelsCenterColor
The color of the center label.
Default: null

labelsCenterItalic
Whether the center label is italic or not.
Default: null

labelsCenterBold
Whether the center label is bold or not.
Default: null

labelsCenterUnitsPre
Units that are pre-pended to the center label.
Default: null

labelsCenterUnitsPost
Units that are appended to the center label.
Default: null

labelsCenterPoint
The character used as the decimal point for the center label.
Default: null

labelsCenterThousand
The character used as the thousand separator for the center label.
Default: null

labelsCenterDecimals
The number of decimals to apply to the center label.
Default: null

labelsCenterSpecific
The specific text to use as the center label.
Default: null

labelsCenterFormatter
A function used as the formatter for the center label. This function should look like this:
labelsCenterFormatter: function (obj, num)
{
}

Default: null

Title properties

PropertyDescriptionDefault
titleThe title of the chart.(An empty string)
titleXThe specific X coordinate of the title. This can also be a string that looks like this: "+10" or "-10" in which case it's added to the calculated position.null
titleYThe specific Y coordinate of the title. This can also be a string that looks like this: "+10" or "-10" in which case it's added to the calculated position.null
titleHalignThe horizontal alignment of the title.center
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 property.null
titleBoldWhether the title is bold or not.null
titleItalicWhether the title is italic or not.null
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 marginTop value.(An empty string)
titleSubtitleColorThe color of the subtitle.#aaa
titleSubtitleFontThe font used to render the subtitle.null
titleSubtitleSizeThe size of the font used to render the subtitle.null
titleSubtitleBoldWhether the subtitle is bold or not.null
titleSubtitleItalicWhether the subtitle is italic or not.null
title
The title of the chart.
Default: (An empty string)

titleX
The specific X coordinate of the title. This can also be a string that looks like this: "+10" or "-10" in which case it's added to the calculated position.
Default: null

titleY
The specific Y coordinate of the title. This can also be a string that looks like this: "+10" or "-10" in which case it's added to the calculated position.
Default: null

titleHalign
The horizontal alignment of the title.
Default: center

titleColor
The color of the title. It defaults to be the same as the textColor property.
Default: null

titleFont
The font used to render the title.
Default: null

titleSize
The size of the font used to render the title. It defaults to be a little larger than the textSize property.
Default: null

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

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

titleSubtitle
The 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 marginTop value.
Default: (An empty string)

titleSubtitleColor
The color of the subtitle.
Default: #aaa

titleSubtitleFont
The font used to render the subtitle.
Default: null

titleSubtitleSize
The size of the font used to render the subtitle.
Default: null

titleSubtitleBold
Whether the subtitle is bold or not.
Default: null

titleSubtitleItalic
Whether the subtitle is italic or not.
Default: null

Tooltip properties

PropertyDescriptionDefault
tooltipsAn array containing the single tooltip that the chart shows.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 that's applied to the tooltip DIV.RGraph_tooltip
tooltipsEventThe event used for tooltips (either click or mousemove.click
tooltips
An array containing the single tooltip that the chart shows.
Default: null

tooltipsOverride
If 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:
Default: null

tooltipsCssClass
The CSS class that's applied to the tooltip DIV.
Default: RGraph_tooltip

tooltipsEvent
The event used for tooltips (either click or mousemove.
Default: click

Highlight properties

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
highlightStroke
The color of the stroke of the highlight.
Default: rgba(0,0,0,0)

highlightFill
The color of the fill of the highlight.
Default: rgba(255,255,255,0.7)

highlightLinewidth
The linewidth of the stroke of the highlight.
Default: 1

Other properties

PropertyDescriptionDefault
linewidthThe linewidth of the separating lines.0
linewidth
The linewidth of the separating lines.
Default: 0

Methods

 

obj.get(name)

This can be used to get properties if necessary. It's normally used after the chart is drawn if you need to get parameters (if you're doing custom coding for example).

 

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 beforedraw or draw) to the chart object. For example:

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

 

obj.exec(func)

This function can be used to execute a function (immediately). It's not event based (ie it doesn't run when something happens) - it just runs immediately - and only once. You might use it when you need to get something from the chart when it's drawn and then call the redraw function. Because this function only runs once the RGraph.SVG.redraw() function would not cause a loop - which would happen if you used the draw event.

obj.exec(function (obj)
{
    // Put your code here
});

 

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>