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> new RGraph.SVG.SemiCircularProgress({ id: 'chart-container', min: 0, max: 100, value:50, options: { labelsCenterDecimals: 1, tooltips: 'Progress: %{value}%', tooltipsCss: { backgroundColor: '#333', fontWeight: 'bold', fontSize: '14pt', opacity: 0.85 } } }).draw(); </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:
obj.nodes.background
obj.nodes.bar
obj.nodes.labelsCenter
obj.nodes.labelsMax
obj.nodes.labelsMin
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
- Margin properties
- Background properties
- Color properties
- Labels and text properties
- Title properties
- Tooltip properties
- Highlight properties
- Other properties
Chart configuration properties
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
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
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
Property | Description | Default |
---|---|---|
colors | The color to be used for the progress bar. | ['#0c0'] |
colorsStroke | The color of the outline of the progress bar. | #666 |
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
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
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
titleOffsetx
An offset value which is added to the calculated X coordinate.
Default: 0
titleOffsety
An offset value which is added to the calculated Y coordinate.
Default: 0
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
Property | Description | Default |
---|---|---|
tooltips | An array containing the single tooltip that the chart shows. | 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:
| null |
tooltipsEvent | The event used for tooltips (either click or mousemove . | click |
tooltipsFormattedPoint | When using formatted tooltip strings this is used as the point when using the %{value_formatted} option. | . |
tooltipsFormattedThousand | When using formatted tooltip strings this is used as the thousand separator when using the %{value_formatted} option. | , |
tooltipsFormattedDecimals | When using formatted tooltip strings this specifies the number of decimals when using the %{value_formatted} option. | 0 |
tooltipsFormattedUnitsPre | When using formatted tooltip strings these units are prepended to the number when using the %{value_formatted} option. | (an empty string) |
tooltipsFormattedUnitsPost | When using formatted tooltip strings these units are appended to the number when using the %{value_formatted} option. | (an empty string) |
tooltipsFormattedKeyLabels | The labels that are used in the formatted tooltip key. | [] (an empty array) |
tooltipsFormattedKeyColors | The colors that are used in the formatted tooltip key. Normally these are automatically taken from the colors on the chart, but can be specified differently using this property. | null |
tooltipsFormattedKeyColorsShape | This is the shape that's used in the tooltip key. It can be square or circle | square |
tooltipsFormattedKeyColorsCss | By using this property you can add CSS values to the key color shape that appears in the tooltip key. Note the property name is "color" and not "colors" like previous properties. It should be an object of CSS properties like this: tooltipsFormattedKeyColorsCss : { border: "1 px solid #ddd"; } | null |
tooltipsFormattedListType | With this property you can switch between an unordered list (the default) and an ordered list. Possible values are ul and ol . | ul |
tooltipsFormattedListItems | This should be a two-dimension array of the list items that are to be shown for all of the tooltips. An example of this property is:tooltipsFormattedListItems: [ ['Bill','Jerry','Berty'], // First tooltip ['Gill','Carrie','Lucy'], // Second tooltip ['Pob','Nobby','Hilda'] // Third tooltip ]You can use CSS to style this list - for example: .RGraph_tooltip ul#rgraph_formatted_tooltips_list li { text-align: left; color: yellow; } | null |
tooltipsFormattedTableHeaders | When showing a table in the tooltips this can be an array of headers for the table. These are added to the tooltip using <th> tags. | null |
tooltipsFormattedTableData | This is the data that is added to the table. This is a 3-dimensional array so it's easy to make a mistake. See the example in the canvas documentation, copy the code from it and then modify it suit. You'll create fewer bugs this way. | null) |
tooltipsPointer | By default the tooltips have a small triangular pointer that points to the shape that was clicked on. You can turn this off with this property. | true |
tooltipsPointerCss | If you want any CSS values applied to the tooltips pointer (for example a CSS border) then specify an object containing those values to this property. For example: tooltips: { borderLeft: 'gray 2px solid', borderBottom: 'gray 2px solid' } | null |
tooltipsPositionStatic | The new default (as of August 2020) is for tooltips to be positioned statically and not be dependent on the mouse position. If you don't want this for whatever reason, you can disable it with this setting. When you set it to false tooltips are positioned next to the mouse pointer. | true |
tooltipsCss | If you want to specify some CSS that gets applied to all of the tooltips, but don't want to use the RGraph.tooltips.style object (which gets applied to all of the tooltips on the page for every chart) you can use this property to give some per-object CSS for the tooltips. These are CSS styles that get applied to all of the tooltips for the specific object only. It should look like this:tooltipsCss: { fontFamily: 'Verdana', fontSize: '20pt' } | null |
tooltipsCssClass | The CSS class that's applied to the tooltip DIV. | RGraph_tooltip |
tooltipsOffsetx | This property allows you to shift the tooltips left or right. | 0 |
tooltipsOffsety | This property allows you to shift the tooltips up or down. | 0 |
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: 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 aclick
ormousemove
event).
Default: null
tooltipsEvent
The event used for tooltips (either
click
or mousemove
.Default: click
tooltipsFormattedPoint
When using formatted tooltip strings this is used as the point when using the %{value_formatted} option.
Default: .
tooltipsFormattedThousand
When using formatted tooltip strings this is used as the thousand separator when using the %{value_formatted} option.
Default: ,
tooltipsFormattedDecimals
When using formatted tooltip strings this specifies the number of decimals when using the %{value_formatted} option.
Default: 0
tooltipsFormattedUnitsPre
When using formatted tooltip strings these units are prepended to the number when using the %{value_formatted} option.
Default: (an empty string)
tooltipsFormattedUnitsPost
When using formatted tooltip strings these units are appended to the number when using the %{value_formatted} option.
Default: (an empty string)
tooltipsFormattedKeyLabels
The labels that are used in the formatted tooltip key.
Default: [] (an empty array)
tooltipsFormattedKeyColors
The colors that are used in the formatted tooltip key. Normally these are automatically taken from the colors on the chart, but can be specified differently using this property.
Default: null
tooltipsFormattedKeyColorsShape
This is the shape that's used in the tooltip key. It can be
square
or circle
Default: square
tooltipsFormattedKeyColorsCss
By using this property you can add CSS values to the key color shape that appears in the tooltip key. Note the property name is "color" and not "colors" like previous properties. It should be an object of CSS properties like this:
tooltipsFormattedKeyColorsCss : { border: "1 px solid #ddd"; }
Default: null
tooltipsFormattedListType
With this property you can switch between an unordered list (the default) and an ordered list. Possible values are
ul
and ol
.Default: ul
tooltipsFormattedListItems
This should be a two-dimension array of the list items that are to be shown for all of the tooltips. An example of this property is:
tooltipsFormattedListItems: [ ['Bill','Jerry','Berty'], // First tooltip ['Gill','Carrie','Lucy'], // Second tooltip ['Pob','Nobby','Hilda'] // Third tooltip ]You can use CSS to style this list - for example:
.RGraph_tooltip ul#rgraph_formatted_tooltips_list li { text-align: left; color: yellow; }
Default: null
tooltipsFormattedTableHeaders
When showing a table in the tooltips this can be an array of headers for the table. These are added to the tooltip using
<th>
tags.Default: null
tooltipsFormattedTableData
This is the data that is added to the table. This is a 3-dimensional array so it's easy to make a mistake. See the example in the canvas documentation, copy the code from it and then modify it suit. You'll create fewer bugs this way.
Default: null)
tooltipsPointer
By default the tooltips have a small triangular pointer that points to the shape that was clicked on. You can turn this off with this property.
Default: true
tooltipsPointerCss
If you want any CSS values applied to the tooltips pointer (for example a CSS border) then specify an object containing those values to this property. For example:
tooltips: { borderLeft: 'gray 2px solid', borderBottom: 'gray 2px solid' }
Default: null
tooltipsPositionStatic
The new default (as of August 2020) is for tooltips to be positioned statically and not be dependent on the mouse position. If you don't want this for whatever reason, you can disable it with this setting. When you set it to
false
tooltips are positioned next to the mouse pointer.Default: true
tooltipsCss
If you want to specify some CSS that gets applied to all of the tooltips, but don't want to use the
RGraph.tooltips.style
object (which gets applied to all of the tooltips on the page for every chart) you can use this property to give some per-object CSS for the tooltips. These are CSS styles that get applied to all of the tooltips for the specific object only. It should look like this:tooltipsCss: { fontFamily: 'Verdana', fontSize: '20pt' }
Default: null
tooltipsCssClass
The CSS class that's applied to the tooltip DIV.
Default: RGraph_tooltip
tooltipsOffsetx
This property allows you to shift the tooltips left or right.
Default: 0
tooltipsOffsety
This property allows you to shift the tooltips up or down.
Default: 0
Highlight properties
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
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
});
obj.responsive(configuration)
The responsive()
function helps your charts respond to different browser window
sizes and screen resolutions. For example for smaller screens you might want to have angled labels
or show shorter versions of them completely.
The responsive()
function is documented on its own page here.
Animation Effects
These effects are available and can be used instead of thedraw()
function.
- The
Grow()
effect (demo available in the download archive)
<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>