Semi-circular Progress bar
Example
<script> scp = new RGraph.SVG.SemiCircularProgress({ id: 'chart-container', min: 0, max: 200, value: [50,30,60], options: { colors: ['rgba(0,255,0,0.25)', 'rgba(255,0,0,0.25)', 'rgba(255,255,0,0.25)' ], marginRight: 75, marginLeft: 75, marginTop: 50, scale: true, backgroundColor: '#E8FAE8', backgroundColorOpacity: 1, backgroundGrid: true, scaleLabelsSize: 10, scaleLabelsCount: 20, scaleUnitsPost: '%', backgroundGridRadialsCount: 20, labelsCenterUnitsPost: '%', labelsCenterDecimals: 1, tooltips: 'Amount: %{value_formatted} boxes', tooltipsCss: { fontSize: '20pt', fontWeight: 'bold' } } }).draw(); </script>
The obj.coords property
The obj.coords
array is new for version 6.05 and
provides an alternative to the obj.nodes
properties - being more like the canvas
way of storing
coordinates to shapes. The object is an array of objects
which each contain the details of the segments that are
drawn on the chart. If you want to, you can replay these
coordinates by using the RGraph api
method
RGraph.SVG.TRIG.getArcPath3
and
then using the resulting path as the argument when you
create a path node, like this:
// Create the outer arc path var arcPath1 = RGraph.SVG.TRIG.getArcPath3({ cx: scp.coords[0].cx, cy: scp.coords[0].cy, radius: scp.coords[0].radiusOuter, start: scp.coords[0].start, end: scp.coords[0].end, anticlockwise: false, lineto:false }); // Crete the inner arc path var arcPath2 = RGraph.SVG.TRIG.getArcPath3({ cx: scp.coords[0].cx, cy: scp.coords[0].cy, radius: scp.coords[0].radiusInner, start: scp.coords[0].end, end: scp.coords[0].start, anticlockwise: true, lineto: true }); // Now create an SVG path object out of the two paths created above var path = scp.create('path', null, { d: '{1} {2} z'.format(arcPath1, arcPath2), stroke: 'black', fill: 'transparent' });
The obj.nodes property
As well as coordinates, the Semi-circular Progress mmeter
aintains
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 shown above.
- Chart configuration properties
- Margin properties
- Background properties
- Color properties
- Labels and text properties
- Scale 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. As well as a number this can be a string like this:
+25
-25
And in that case that number is used to adjust the x-axis
coordinate.Default: null
centery
If required, you can position the progress bar using this instead of the margins. As well as a number this can be a string like this:
+25
-25
And in that case that number is used to adjust the y-axis
coordinate.Default: null
radius
If required, you can size the progress bar using this instead of the margins. As well as a number this can be a string like this:
+25
-25
And in that case that number is used to adjust the radius.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 color of the background fill.
Default: Gradient(white:#aaa)
backgroundFillOpacity
The
opacity
of the background fill color.Default: 0.25
backgroundGrid
Whether the background grid is drawn or not.
Default: true
backgroundGridLinewidth
The
linewidth
of the background grid.Default: 1
backgroundGridColor
The color of the background grid.
Default: #ddd
backgroundGridRadials
Whether the radial lines (the lines that emanate from the center coordinates) are drawn or not.
Default: true
backgroundGridRadialsCount
The number of radial lines that are drawn.
Default: 10
backgroundGridCircles
Whether the
semi-circular border bar
lines are drawn on the background grid.Default: true
backgroundGridMargin
This is the distance that the background grid extends to.
Default: 20
Color properties
The color to be used for the progress bar.
Default: [#6d6, #FFA5A5, #A0A2F8, yellow, gray, pink, orange, cyan, green]
colorsStroke
The color of the outline of the progress bar.
Default: transparent
Labels and text properties
Property | Description | Default |
---|---|---|
textFont | The font used to render the text. | Arial, Verdana, sans-serif |
textSize | The size of the text. | 12 |
textColor | The color of the labels. | black |
textItalic | Whether the labels are italic or not. | false |
textBold | Whether the labels are bold or not. | false |
text | This allows you to add custom text to your chart if you want to. There's a dedicated page that describes this option here. | null |
labelsMin | Whether to show the minimum label. | true |
labelsMinFont | The font used to render the minimum label. | null |
labelsMinSize | The size of the minimum label. | null |
labelsMinColor | The color of the minimum label. | null |
labelsMinItalic | Whether the minimum label is italic or not. | null |
labelsMinBold | Whether the minimum label is bold or not. | null |
labelsMinUnitsPre | Units that are pre-pended to the minimum label. | null |
labelsMinUnitsPost | Units that are appended to the minimum label. | null |
labelsMinPoint | The character that's used as the decimal point for the minimum label. | null |
labelsMinThousand | The character that's used as the thousand separator for the minimum label. | null |
labelsMinDecimals | The number of decimals to apply to the minimum label. | null |
labelsMinSpecific | The specific text to use as the minimum label. | null |
labelsMinFormatter | A function that's used as the formatter for the minimum label. This function should look like this: labelsMinFormatter: function (obj, num) { } | null |
labelsMax | Whether to show the maximum label. | true |
labelsMaxFont | The font used to render the maximum label. | null |
labelsMaxSize | The size of the maximum label. | null |
labelsMaxColor | The color of the maximum label. | null |
labelsMaxItalic | Whether the maximum label is italic or not. | null |
labelsMaxBold | Whether the maximum label is bold or not. | null |
labelsMaxUnitsPre | Units that are pre-pended to the maximum label. | null |
labelsMaxUnitsPost | Units that are appended to the maximum label. | null |
labelsMaxPoint | The character that's used as the decimal point for the maximum label. | null |
labelsMaxThousand | The character that's used as the thousand separator for the maximum label. | null |
labelsMaxDecimals | The number of decimals to apply to the maximum label. | null |
labelsMaxSpecific | The specific text to use as the maximum label. | null |
labelsMaxFormatter | A function that's used as the formatter for the maximum label. This function should look like this: labelsMaxFormatter: function (obj, num) { } | null |
labelsCenter | Whether to show the center label. | true |
labelsCenterIndex | If you're showing multiple values on your chart this is the index of the value in the data array that is used as the center label. | 0 |
labelsCenterFont | The font used to render the center label. | null |
labelsCenterSize | The size of the center label. | 40 |
labelsCenterColor | The color of the center label. | null |
labelsCenterItalic | Whether the center label is italic or not. | null |
labelsCenterBold | Whether the center label is bold or not. | null |
labelsCenterUnitsPre | Units that are pre-pended to the center label. | null |
labelsCenterUnitsPost | Units that are appended to the center label. | null |
labelsCenterPoint | The character that's used as the decimal point for the center label. | null |
labelsCenterThousand | The character that's used as the thousand separator for the center label. | null |
labelsCenterDecimals | The number of decimals to apply to the center label. | null |
labelsCenterSpecific | The specific text to use as the center label. | null |
labelsCenterFormatter | A function that's used as the formatter for the center label. This function should look like this: labelsCenterFormatter: function (obj, num) { } | null |
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
text
This allows you to add custom text to your chart if you want to. There's a dedicated page that describes this option here.
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 that's used as the decimal point for the minimum label.
Default: null
labelsMinThousand
The character that's 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 that's 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 that's used as the decimal point for the maximum label.
Default: null
labelsMaxThousand
The character that's 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 that's 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
labelsCenterIndex
If you're showing multiple values on your chart this is the index of the value in the data array that is used as the center label.
Default: 0
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 that's used as the decimal point for the center label.
Default: null
labelsCenterThousand
The character that's 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 that's used as the formatter for the center label. This function should look like this:
labelsCenterFormatter: function (obj, num) { }
Default: null
Scale properties
Whether a scale is shown on the chart. If yes the minimum and maximum value that you give to the constructor will be used by default.
Default: false
scaleMin
This is the minimum value for the scale. This just affects the scale on the chart - not the bar itself.
Default: 0
scaleMax
This is the maximum value for the scale. You don't have to give it and if you don't it will be the same as the max value that you give when you create the chart. This just affects the scale on the chart - not the bar that represents the value.
Default: null
scaleLabelsCount
This property allows you to stipulate how many labels there are on the scale.
Default: 10
scaleLabelsColor
The color of the labels (defaults to the
textColor
property).Default: null
scaleLabelsFont
The font of the labels (defaults to the
textFont
property)Default: null
scaleLabelsSize
The size of the labels (defaults to the
textSize
property)Default: null
scaleLabelsBold
Whether the scale labels are bold or not (defaults to the
textBold
property)Default: null
scaleLabelsItalic
Whether the scale labels are italic or not (defaults to the
textItalic
property)Default: null
scaleLabelsOffsetr
If you want to offset the scale labels (radially) you can do that with this property.
Default: 0
scaleLabelsOffsetx
If you want to offset the scale labels (in the horizontal direction) you can do that with this property.
Default: 0
scaleLabelsOffsety
If you want to offset the scale labels (in the vertical direction) you can do that with this property.
Default: 0
scaleUnitsPre
These units are prepended to the scale numbers on the chart.
Default: A blank string
scaleUnitsPost
These units are appended to the scale numbers on the chart.
Default: A blank string
scaleDecimals
This stipulates how many decimal places are shown on the scale numbers on the chart.
Default: 0
scalePoint
The character that's used as the decimal point for the scale.
Default: .
scaleThousand
The character that's used as the thousand separator for the scale.
Default: ,
scaleFormatter
If you want to handle the formatting of the scale yourself you can do so with this property. It should be a function that returns the formatted number.
Default: null
Title properties
The title of the chart.
Default: (An empty string)
titleX
The specific
x-axis
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-axis
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 that is added to the calculated
x-axis
coordinate.Default: 0
titleOffsety
An offset value that is added to the calculated
y-axis
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. You can also check the canvas tooltips documentation for more information. | null |
tooltipsOverride | This can be a function that 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: "1px 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 (a css border, for example) then specify an object containing those values to this property. For example: tooltipsPointerCss: { borderLeft: 'gray 2px solid', borderBottom: 'gray 2px solid' } | null |
tooltipsPointerOffsetx | This allows you to adjust the horizontal position of the tooltips pointer. | 0 |
tooltipsPointerOffsety | This allows you to adjust the vertical position of the tooltips pointer. | 0 |
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.SVG.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. You can also check the canvas tooltips documentation for more information.
Default: null
tooltipsOverride
This can be a function that 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 containhtml
(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: "1px 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 (a css
border, for example) then specify an object containing those values to this property. For example: tooltipsPointerCss: { borderLeft: 'gray 2px solid', borderBottom: 'gray 2px solid' }
Default: null
tooltipsPointerOffsetx
This allows you to adjust the horizontal position of the tooltips pointer.
Default: 0
tooltipsPointerOffsety
This allows you to adjust the vertical position of the tooltips pointer.
Default: 0
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.SVG.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
Property | Description | Default |
---|---|---|
linewidth | The linewidth of the separating lines. | 1 |
adjustable | This property, when set to true , allows the Semi-circular Progress bar to be dynamically adjusted. There are three events which are asscociated with adjusting:
adjustbegin event fires when you first click on the indicator bar - much like the mousedown event. The adjust event fires during adjusting - much like the mousemove event. And the adjustend event fires when you finish adjusting - much like the mouseup event. There's a demo of an adjustable chart in the download archive called demos/svg-scp-adjustable.html | false |
responsive | This option is new to the July 2023 release (v6.13) and allows you to inline the responsive configuration instead of appending it on to the end of the object it as a function. The documentation and demo pages have been updated to use this new option. You can read more about the responsive feature by reading the responsive configuration page. | null |
The
linewidth
of the separating lines.Default: 1
adjustable
This property, when set to
true
, allows the Semi-circular Progress bar
to be dynamically adjusted. There are three events which are asscociated with adjusting:adjustbegin
adjust
adjustend
adjustbegin
event fires when you first click on the indicator bar - much like the mousedown
event. The adjust
event fires during adjusting - much like the mousemove
event. And the adjustend
event fires when you finish adjusting - much like the mouseup
event. There's a demo of an adjustable chart in the download archive called demos/svg-scp-adjustable.html
Default: false
responsive
This option is new to the July 2023 release (v6.13) and allows you to inline the responsive configuration instead of appending it on to the end of the object it as a function. The documentation and demo pages have been updated to use this new option. You can read more about the responsive feature by reading the responsive configuration page.
Default: null
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 RGraph.SVG.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.
Update: There is now the responsive configuration option available to you and this is now the preferred method of configuration.
The responsive function and configuration option are documented on their own page here.
Events
RGraph supports custom events that allow you to easily add interactivity to your charts if required. The following events are available:
beforedraw
This event fires at the start of thedraw
method before anything has been done.draw
This event fires at the end of thedraw
function.firstdraw
This event fires at the end of thedraw
function - but only the first time and so it fires only once after the firstdraw
call.beforetooltip
This event fires at the start of the tooltip showing process.tooltip
This event fires after a tooltip has been shown.
new RGraph.SVG.SemiCircularProgress({ id: 'chart-container', min: 0, max: 100, value:50, options: { } }).on('tooltip', function (obj) { console.log('The draw event has fired'); }).draw();
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>