SVG Semi-circular Progress charts API reference

  Read comments...

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

 

Example

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

The code above produces a chart like this:

 

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

Properties: centerx, centery, radius, width

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

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

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

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

 

Margins

Properties: gutterLeft, gutterRight, gutterTop, gutterBottom

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

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

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

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

 

Background

Properties: backgroundStrokeLinewidth, backgroundStroke, backgroundFill, backgroundFillOpacity

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

 

Colors

Properties: colors, strokestyle

colors
The color to be used for the progress bar.
Default: ['#0c0']

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

 

Labels and text

Properties: textFont, textSize, textColor, textItalic, textBold, unitsPre, unitsPost, scalePoint, scaleThousand, scaleDecimals, scaleFormatter, labelsMin, labelsMinFont, labelsMinSize, labelsMinColor, labelsMinItalic, labelsMinBold, labelsMinUnitsPre, labelsMinUnitsPost, labelsMinPoint, labelsMinThousand, labelsMinDecimals, labelsMinSpecific, labelsMinFormatter, labelsMax, labelsMaxFont, labelsMaxSize, labelsMaxColor, labelsMaxItalic, labelsMaxBold, labelsMaxUnitsPre, labelsMaxUnitsPost, labelsMaxPoint, labelsMaxThousand, labelsMaxDecimals, labelsMaxSpecific, labelsMaxFormatter, labelsCenter, labelsCenterFont, labelsCenterSize, labelsCenterColor, labelsCenterItalic, labelsCenterBold, labelsCenterUnitsPre, labelsCenterUnitsPost, labelsCenterPoint, labelsCenterThousand, labelsCenterDecimals, labelsCenterSpecific, labelsCenterFormatter

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

textSize
The size of the text.
Default: 10

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

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

unitsPost
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 seperator
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 seperator 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 seperator 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: #666

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

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

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 seperator 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: title, titleX, titleY, titleHalign, titleValign, titleColor, titleFont, titleSize, titleBold, titleItalic, titleSubtitle, titleSubtitleX, titleSubtitleY, titleSubtitleHalign, titleSubtitleValign, titleSubtitleColor, titleSubtitleFont, titleSubtitleSize, titleSubtitleBold, titleSubtitleItalic

title
The title of the chart.
Default: (An empty string)

titleX
The specific X coordinate of the title.
Default: null

titleY
The specific Y coordinate of the title.
Default: null

titleHalign
The horizontal alignment of the title.
Default: center

titleValign
The vertical alignment of the title.
Default: bottom

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: false

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

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

titleSubtitleX
The specific X coordinate of the subtitle.
Default: null

titleSubtitleY
The specific Y coordinate of the subtitle.
Default: null

titleSubtitleHalign
The horizontal alignment of the subtitle.
Default: center

titleSubtitleValign
The vertical alignment of the subtitle.
Default: top

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. It defaults to be the same as the textSize setting.
Default: null

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

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

 

Tooltips

Properties: tooltips, tooltipsOverride, tooltipsCssClass, tooltipsEvent

tooltips
An array of tooltips for the chart. This array should NOT be multidimensional - even for stacked or grouped charts.
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 thats applied to the tooltip DIV.
Default: RGraph_tooltip

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

 

Highlight

Properties: highlightStroke, highlightFill, highlightLinewidth

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

 

Attribution

Properties: attribution, attributionX, attributionY, attributionHref, attributionHalign, attributionValign, attributionFont, attributionSize, attributionColor, attributionItalic, attributionBold

attribution
Whether to show the attribution link or not. If you're going to link to the RGraph website elsewhere on your site then set this to false.
Default: true

attributionX
The X coordinate of the link. This can be a number (in which case it's treated as the absolute coordinate) or it can be a string starting with a + or - (in which case it's treated as an adjustment to the default value).
Default: (bottom right corner of the SVG tag)

attributionY
The Y coordinate of the link. This can be a number (in which case it's treated as the absolute coordinate) or it can be a string starting with a + or - (in which case it's treated as an adjustment to the default value).
Default: (bottom right corner of the SVG tag)

attributionHref
The href of the link (ie the page to link to).
Default: http://www.rgraph.net/svg/index.html

attributionHalign
The horizontal alignment of the link.
Default: right

attributionValign
The vertical alignment of the link
Default: bottom

attributionFont
The font used to render the link.
Default: sans-serif

attributionSize
The point size of the link.
Default: 8

attributionColor
The color of the link.
Default: gray

attributionItalic
Whether the link is italic or not.
Default: false

attributionBold
Whether the link is bold or not.
Default: false

 

Other

Properties: linewidth

linewidth
The linewidth of the seperating lines.
Default: 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>
If you like RGraph please share it:

Comments