About
RGraph is a JavaScript charts library based on HTML5 SVG and canvas. RGraph is mature (over 15 years old) and has a wealth of features making it an ideal choice to show charts on your website.

More »

 

License
RGraph can be used for free under the GPL or if that doesn't suit your situation there's an inexpensive (£99) commercial license available.

More »

 

Download
Get the latest version of RGraph (version 6.16) from the download page. There's also older versions available, minified files and links to cdnjs.com hosted libraries.

More »

Pie chart

Example

An example of Pie chart with tooltips
<script>
    labels = ['Fred','Rich','John','Paul','Jason','Hoolio','Kevin'];

    new RGraph.Pie({
        id: 'cvs',
        data: [564,155,499,611,322,568,389],
        options: {
            marginLeft: 100,
            marginRight: 100,
            tooltips: '<b>Results:</b><br />%{key}',
            tooltipsFormattedKeyLabels: labels,
            labels: labels,
            linewidth: 2,
            colorsStroke: 'white',
            shadow: false,
            tooltipsCss: {
                fontSize: '16pt',
                textAlign: 'left'
            },
            exploded: [25]
        }
    }).draw();
</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.

obj.set('name', 'value');

Chart configuration properties

Name: centerx
Description: 
If required, you can position the Pie chart using this instead of the margins. As well as a number, that gives the exact coordinate of the center position of the chart, this can also be a string like this: centerx: '+25' or this: centerx: '-40' which is then used to adjust the calculated coordinate.
Default: null
Name: centery
Description: 
If required, you can position the Pie chart using this instead of the margins. As well as a number, that gives the exact coordinate of the center position of the chart, this can also be a string like this: centery: '+25' or this: centery: '-40' which is then used to adjust the calculated coordinate.
Default: null
Name: radius
Description: 
If required, you can size the Pie chart using this instead of the margins. As well as a number, that gives the exact size of the chart, this can also be a string like this: radius: '+25' or this: radius: '-40' which is then used to adjust the calculated coordinate.
Default: null

Margin properties

Name: marginLeft
Description: 
The left margin of the chart, (the margin is where the labels and title are)).
Default: 35
Name: marginRight
Description: 
The right margin of the chart, (the margin is where the labels and title are).
Default: 35
Name: marginTop
Description: 
The top margin of the chart, (the margin is where the labels and title are).
Default: 35
Name: marginBottom
Description: 
The bottom margin of the chart, (the margin is where the labels and title are).
Default: 35

Color properties

Name: colors
Description: 
Colors to be used for the pie segments.
Default: ['rgb(255,0,0)', '#ddd', 'rgb(0,255,0)', 'rgb(0,0,255)', 'rgb(255,255,0)', 'rgb(0,255,255)', 'red', 'pink', 'black', 'white']
Name: colorsStroke
Description: 
The color of the separating lines. This can also be an array of different colors - eg pie.set('colorsStroke', ['red', 'blue', 'green']);.
Default: #999

Labels and text properties

Name: textAccessible
Description: 
A new feature in 2016 that allows you to use dom text in place of canvas text. It makes for higher quality text that you can also select if desired (for copy/paste operations). It won't fit all situations and you can read more about the DOM text feature here. A good way to control borders/margins/padding etc is not to set them on the canvas but to wrap the canvas in a div and set them on that like this:
<div style="margin-left: 50px; display: inline-block">
    <canvas id="cvs" width="650" height="250"></canvas>
</div>
Default: false
Name: textAccessibleOverflow
Description: 
This can be visible or hidden and it controls whether the text is clipped to the edges of the canvas. It defaults to be visible and means you can set small margins if you wish.
Default: visible
Name: textAccessiblePointerevents
Description: 
This controls whether the dom text responds to mouse-based events or not (it sets the pointer-events css property to none).
Default: true
Name: textSize
Description: 
The size of the text.
Default: 10
Name: textFont
Description: 
The font used to render the text.
Default: Arial, Verdana, sans-serif
Name: textColor
Description: 
The color of the labels.
Default: black
Name: textItalic
Description: 
Whether the text on the chart is italic or not.
Default: false
Name: textBold
Description: 
Whether the text on the chart is bold or not.
Default: false
Name: labels
Description: 
An array of labels to be used for the chart. You can also give this option a string if you prefer and use formatted labels
Default: An empty array
Name: labelsFont
Description: 
The font used to render the labels.
Default: null
Name: labelsSize
Description: 
The size of the labels.
Default: null
Name: labelsColor
Description: 
The color of the labels.
Default: null
Name: labelsBold
Description: 
Whether the labels are bold or not.
Default: null
Name: labelsItalic
Description: 
Whether the labels are italic or not.
Default: null
Name: labelsRadiusOffset
Description: 
When showing labels this allows you to specify an offset for the radius of them.
Default:  0
Name: labelsFormattedDecimals
Description: 
When using formatted labels this is the number of decimals that are applied to the %{value_formatted} macro.
Default:  0
Name: labelsFormattedPoint
Description: 
When using formatted labels this is the decimal point character that's used with the %{value_formatted} macro.
Default: .
Name: labelsFormattedThousand
Description: 
When using formatted labels this is the thousand separator character that's used with the %{value_formatted} macro.
Default: ,
Name: labelsFormattedUnitsPre
Description: 
When using formatted labels these are the units that are prepended to the number with the %{value_formatted} macro.
Default: (an empty string)
Name: labelsFormattedUnitsPost
Description: 
When using formatted labels these are the units that are appended to the number with the %{value_formatted} macro.
Default: (an empty string)
Name: labelsSticksLinewidth
Description: 
Sets the linewidth of the label sticks.
Default: 1
Name: labelsList
Description: 
A new way of organising the labels - this should help avoid label text overlaps.
Default: true
Name: labelsListLeftOffsetx
Description: 
A horizontal offset for the left labels.
Default:  0
Name: labelsListLeftOffsety
Description: 
A vertical offset for the left labels.
Default:  0
Name: labelsListRightOffsetx
Description: 
A horizontal offset for the right labels.
Default:  0
Name: labelsListRightOffsety
Description: 
A vertical offset for the right labels.
Default:  0
Name: labelsClass
Description: 
This property allows you to add your own css class to the labels which you can then use for styling purposes or to make retrieving the span tags easier (the dom elements). If you inspect the labels in your browser's javascript console (you will first need to enable the textAccessiblePointerevents property) you will be able to see the other css classes that are assigned to the labels.
Default: [none]
Name: labelsIngraph
Description: 
This shows labels inside each segment. From v6.11 these labels are only shown if there's sufficient space in the segment for them. If there's not enough space for a particular label then that label isn't shown.
Default: false
Name: labelsIngraphBounding
Description: 
Whether the in-graph labels are surrounded by a bounding box.
Default: false
Name: labelsIngraphBoundingFill
Description: 
The fill color of the bounding square.
Default: white
Name: labelsIngraphBoundingStroke
Description: 
The stroke color of the bounding square.
Default: rgba(0,0,0,0)
Name: labelsIngraphUnitsPre
Description: 
This string is prepended to the label.
Default: (empty string)
Name: labelsIngraphUnitsPost
Description: 
This string is appended to the label.
Default: (empty string)
Name: labelsIngraphRadius
Description: 
If specified this is the radius that the labels are positioned at. If it's a number between 0 and 2 it is multiplied with the radius to get the position. If it's above 2 though it's used as the exact radius.
Default: null
Name: labelsIngraphRadiusOffset
Description: 
If specified this is added to the radius that has been calculated.
Default:  0
Name: labelsIngraphPoint
Description: 
The character that's used as the decimal point.
Default: .
Name: labelsIngraphThousand
Description: 
The character that's used as the thousand separator.
Default: ,
Name: labelsIngraphDecimals
Description: 
The number of decimals shown on the ingraph labels.
Default:  0
Name: labelsIngraphColor
Description: 
The color of the labels.
Default: null
Name: labelsIngraphFont
Description: 
The font to use for the ingraph labels.
Default: null
Name: labelsIngraphSize
Description: 
The size of the ingraph labels.
Default: null
Name: labelsIngraphBold
Description: 
Whether the ingraph labels are bold or not.
Default: null
Name: labelsIngraphItalic
Description: 
Whether the ingraph labels are italic or not.
Default: null
Name: labelsIngraphSpecific
Description: 
Instead of the values you can use this option to specify the text that is shown. This can be an array of strings (with or without formatting macros) or it can also be a single string, again, with or without formatting macros. Though when it's a single string it does make plenty of sense to include some formatting macros. You can read more about what macros are available here.
Default: null
Name: labelsIngraphpecificFormattedDecimals
Description: 
The number of decimals that are displayed as part of the number. This applies to the %{value_formatted} macro.
Default:  0
Name: labelsIngraphpecificFormattedPoint
Description: 
The character used as the decimal point. This applies to the %{value_formatted} macro.
Default: .
Name: labelsIngraphpecificFormattedThousand
Description: 
The character used as the thousand separator. This applies to the %{value_formatted} macro.
Default: ,
Name: labelsIngraphpecificFormattedUnitsPre
Description: 
Units that are appended to the number. This applies to the %{value_formatted} macro.
Default: 
Name: labelsIngraphpecificFormattedUnitsPost
Description: 
Units that are prepended to the number. This applies to the %{value_formatted} macro.
Default: 
Name: labelsIngraphUndrawn
Description: 
This is not a property that you set. Instead you can read this property (eg var undrawn = myPie.get('labelsIngraphUndrawn')) after your Pie chart has been drawn to find out which of your ingraph labels were not drawn because the label is too big for the segment. You could then use this to add regular labels that contain the information that you want to be displayed to the user. This way no information is lost when your ingraph labels are not shown. There's a demo of this in the download called pie-labelsingraphundrawn.html
Default: null
Name: labelsIngraphUndrawnAsLabels
Description: 
If you want undrawn ingraph labels to be instead drawn as regular labels you can set this to true.
Default: null
Name: labelsIngraphUndrawnAlwaysShow
Description: 
If you set this to true then the ingraph labels will always be shown - even if they don't fit into the segment.
Default: false
Name: labelsCenter
Description: 
This can show a label in the center of the chart. This should be a string - ie the label that you want to show.
Default: [An empty string]
Name: labelsCenterSize
Description: 
The size of the center label.
Default: 26
Name: labelsCenterFont
Description: 
The font used to render the label.
Default: Arial
Name: labelsCenterColor
Description: 
The color of the center label.
Default: black
Name: labelsCenterItalic
Description: 
Whether the center label is italic.
Default: false
Name: labelsCenterBold
Description: 
Whether the center label is bold.
Default: false
Name: labelsCenterOffsetx
Description: 
A horizontal offset for the center label.
Default:  0
Name: labelsCenterOffsety
Description: 
A vertical offset for the center label.
Default:  0
Name: labelsInside
Description: 
For Donut charts - if you want labels on your chart that are positioned inside the donut ring then set this to true.
Default: false
Name: labelsInsideBounding
Description: 
Whether the inside labels are surrounded by a bounding box.
Default: false
Name: labelsInsideBoundingFill
Description: 
The fill color of the bounding square.
Default: rgba(255,255,255,0.75)
Name: labelsInsideBoundingStroke
Description: 
The stroke color of the bounding square.
Default: transparent
Name: labelsInsideColor
Description: 
The color of the labels.
Default: null
Name: labelsInsideSize
Description: 
The size of the labels.
Default: null
Name: labelsInsideFont
Description: 
The font that's used to render the labels.
Default: null
Name: labelsInsideBold
Description: 
Whether the labels are bold or not.
Default: null
Name: labelsInsideItalic
Description: 
Whether the labels are italic or not.
Default: null
Name: labelsInsideDecimals
Description: 
The number of decimals that are used on the number. If this is not enough to show your entire number then rounding may be used on the number.
Default:  0
Name: labelsInsidePoint
Description: 
The character that's used as the decimal point when they're being shown.
Default: .
Name: labelsInsideThousand
Description: 
The character used as the thousand seperator.
Default: ,
Name: labelsInsideUnitsPre
Description: 
These units are prepended to the number.
Default: (an empty string)
Name: labelsInsideUnitsPost
Description: 
These units are appended to the number.
Default: (an empty string)
Name: labelsInsideOffsetr
Description: 
This number is used as an offset to the radius that the labels are rendered at. It can be positive or negative.
Default:  0
Name: labelsInsideHalign
Description: 
The horizontal alignment of the labels. It can be auto or center. When it's set to auto (the default) then the horizontal alignment will be left for labels on the left half of the chart and right for labels on the right side of the chart. When set to center then you may also need to use the labelsInsideOffsetr property to move the labels inwards.
Default: auto
Name: labelsInsideSpecific
Description: 
By default, the values that you give to the Pie chart constructor are used as the labels. Using this property though you can specify exactly what the labels are. This can either be an array of strings (with or without formatting macros), which are used as the labels, or it can be a single string containing formatting macros (for example: labels: '%{property:myNames[%{index}]} (%{value_formatted}').
Default: null
Name: labelsInsideSpecificFormattedDecimals
Description: 
When using formatted labels this is the number of decimals that are applied to the %{value_formatted} macro.
Default:  0
Name: labelsInsideSpecificFormattedPoint
Description: 
When using formatted labels this is the decimal point character that's used with the %{value_formatted} macro.
Default: .
Name: labelsInsideSpecificFormattedThousand
Description: 
When using formatted labels this is the thousand separator character that's used with the %{value_formatted} macro
Default: ,
Name: labelsInsideSpecificFormattedUnitsPre
Description: 
When using formatted labels these are the units that are prepended to the number with the %{value_formatted} macro.
Default: (an empty string)
Name: labelsInsideSpecificFormattedUnitsPost
Description: 
When using formatted labels these are the units that are appended to the number with the %{value_formatted} macro.
Default: (an empty string)
Name: text
Description: 
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

Title properties

Name: title
Description: 
The title of the chart, if any.
Default: null
Name: titleFont
Description: 
The font that the title is rendered in. If not specified the textFont setting is used (usually Arial).
Default: null
Name: titleSize
Description: 
The size of the title. If not specified the size is usually 4pt bigger than the textSize setting.
Default: null
Name: titleBold
Description: 
Whether the title is bold or not.
Default: null
Name: titleItalic
Description: 
Whether the title is italic or not.
Default: null
Name: titleColor
Description: 
The color of the title.
Default: null
Name: titleX
Description: 
To give the exact X coordinate for the title - use this. This can also be a string like this: "-5" - in which case it's converted to a number and added to the calculated coordinate - allowing you to adjust the calculated coordinate.
Default: null
Name: titleY
Description: 
To give the exact Y coordinate for the title - use this. This can also be a string like this: "-5" - in which case it's converted to a number and added to the calculated coordinate - allowing you to adjust the calculated coordinate.
Default: null
Name: titleHalign
Description: 
The horizontal alignment of the title.
Default: center (can change depending on other options)
Name: titleValign
Description: 
The vertical alignment of the title.
Default: center (can change depending on other options)
Name: titleOffsetx
Description: 
You can use this property to adjust the positioning of the title in the horizontal direction (positive values adjust the title to the right and negative values adjust it to the left).
Default:  0
Name: titleOffsety
Description: 
You can use this property to adjust the positioning of the title in the vertical direction (positive values adjust the title downwards and negative values adjust it upwards).
Default:  0
Name: titleSubtitle
Description: 
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: null
Name: titleSubtitleSize
Description: 
The size of the font used to render the subtitle.
Default: null
Name: titleSubtitleColor
Description: 
The color of the subtitle.
Default: #aaa
Name: titleSubtitleFont
Description: 
The font used to render the subtitle.
Default: null
Name: titleSubtitleBold
Description: 
Whether the subtitle is bold or not.
Default: null
Name: titleSubtitleItalic
Description: 
Whether the subtitle is italic or not.
Default: null
Name: titleSubtitleOffsetx
Description: 
Use this property to adjust the horizontal position of the subtitle.
Default:  0
Name: titleSubtitleOffsety
Description: 
Use this property to adjust the vertical position of the subtitle.
Default:  0

Shadow properties

Name: shadow
Description: 
Whether a drop shadow is applied.
Default: true
Name: shadowColor
Description: 
The color of the shadow.
Default: #aaaa
Name: shadowOffsetx
Description: 
The horizontal offset of the shadow.
Default:  0
Name: shadowOffsety
Description: 
The vertical offset of the shadow.
Default:  0
Name: shadowBlur
Description: 
The severity of the shadow blurring effect.
Default: 15

Interactive features properties

Name: tooltips
Description: 
A numerically indexed array of tooltips that are shown when a bar is clicked. These can contain html.
Default: []
Name: tooltipsEvent
Description: 
This is the event that triggers the tooltips. It can be either click or mousemove.
Default: click
Name: tooltipsEffect
Description: 
The effect used for showing tooltips. Possible values are slide fade or none.
Default: slide
Name: tooltipsOverride
Description: 
If you wish to handle showing tooltips yourself, this should be a function object which does just that. There's more information on the tooltips documentation page.
Default: null
Name: tooltipsFormattedPoint
Description: 
When using formatted tooltip strings this is used as the point when using the %{value_formatted} option.
Default: .
Name: tooltipsFormattedThousand
Description: 
When using formatted tooltip strings this is used as the thousand separator when using the %{value_formatted} option.
Default: ,
Name: tooltipsFormattedDecimals
Description: 
When using formatted tooltip strings this specifies the number of decimals when using the %{value_formatted} option.
Default:  0
Name: tooltipsFormattedUnitsPre
Description: 
When using formatted tooltip strings these units are prepended to the number when using the %{value_formatted} option.
Default: (an empty string)
Name: tooltipsFormattedUnitsPost
Description: 
When using formatted tooltip strings these units are appended to the number when using the %{value_formatted} option.
Default: (an empty string)
Name: tooltipsFormattedKeyColors
Description: 
When using formatted tooltip strings you can give specific colors for the %{key} option to use.
Default: null
Name: tooltipsFormattedKeyColorsShape
Description: 
This is the shape that's used in the tooltip key. It can be square or circle
Default: square
Name: tooltipsFormattedKeyColorsCss
Description: 
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
Name: tooltipsFormattedKeyLabels
Description: 
When using formatted tooltip strings these are the labels that are displayed.
Default: [] (an empty array)
Name: tooltipsFormattedListType
Description: 
With this property you can switch between an unordered list (the default) and an ordered list. Possible values are ul and ol.
Default: ul
Name: tooltipsFormattedListItems
Description: 
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
Name: tooltipsFormattedTableHeaders
Description: 
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
Name: tooltipsFormattedTableData
Description: 
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, copy the code from it and then modify it suit. You'll create fewer bugs this way.
Default: null)
Name: tooltipsPointer
Description: 
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
Name: tooltipsPointerCss
Description: 
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
Name: tooltipsPointerOffsetx
Description: 
This allows you to adjust the vertical position of the tooltips pointer.
Default:  0
Name: tooltipsPointerOffsety
Description: 
This allows you to adjust the vertical position of the tooltips pointer (for example, if you add a border you may need to move it down slightly).
Default:  0
Name: tooltipsPositionStatic
Description: 
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
Name: tooltipsCss
Description: 
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
Name: tooltipsCssClass
Description: 
This is the name of the css class the chart uses.
Default: RGraph_tooltip
Name: tooltipsOffsetx
Description: 
This property allows you to shift the tooltips left or right.
Default:  0
Name: tooltipsOffsety
Description: 
This property allows you to shift the tooltips up or down.
Default:  0
Name: tooltipsHotspotIgnore
Description: 
This can be a number of things and can be used to ignore certain tooltip hotspots - which can allow charts to the rear to be clickable. There's an example of this in the download archive called pie-tooltipshotspotignore.html. You can use the transparent color to allow the rear chart to be seen in such a case. It can be:
  • A single boolean value (ie true or false) to enable or disable all of the hotspots - true means the hotspot will be ignored
  • A single number (the zero-indexed number corresponding to the hotspot to ignore)
  • An array of numbers (the numbers are the indexes of hotspots to ignore)
  • An array of boolean true or false values - the position of these values correspond to the index(es) of the segments to ignore (for example [false, false, true, false, false] - true means the corresponding hotspot will be ignored)
Default: null
Name: contextmenu
Description: 
An array of context menu items. More information about context menus is here.
Default: [] (An empty array)
Name: annotatable
Description: 
Whether annotations are enabled for the chart (ie you can draw on the chart interactively.
Default: false
Name: annotatableColor
Description: 
If you do not allow the use of the palette, then this will be the only color allowed for annotations.
Default: black
Name: annotatableLinewidth
Description: 
This is the linewidth of the annotations.
Default: 1

Key properties

The key properties are documented on the key documentation page.

Miscellaneous properties

Name: linewidth
Description: 
By setting this to roughly 5, and setting the colorsStroke to the same color as your background color you will get a segment separation effect.
Default: 1
Name: variant
Description: 
This can be either pie (the default), pie3d, donut or donut3d. Setting this to donut or donut3d is how you get a Donut chart.
Default: pie
Name: variantThreedDepth
Description: 
This is the depth of the 3D Pie chart.
Default: 20
Name: variantDonutWidth
Description: 
This allows you to set how wide the donut is. It can be useful when nesting donuts.
Default: null
Name: highlightStyle
Description: 
Can be either 2d, 3d, outline, invert or a function and determines which style of segment highlighting is used in conjunction with tooltips. If it's a function the function is called and no highlighting is done - ie you should do it all yourself. As of version 5.23 you can also set this to invert. If you do this on a dark background you may find that you need to change the highlight colors setting as well.
Default: 2d
Name: highlightStyleOutlineWidth
Description: 
When outline highlighting for tooltips is used, this controls the width of the highlighting band.
Default: 10
Name: highlightStyleTwodFill
Description: 
When 2D highlighting for tooltips is used, this controls the color of the highlighting. The former name for this property was highlightStyleTwodColor.
Default: rgba(255,255,255,0.5)
Name: highlightStyleTwodStroke
Description: 
When 2D highlighting for tooltips is used, this controls the stroke color of the highlighting.
Default: transparent
Name: highlightStyleTwodLinewidth
Description: 
When 2D highlighting for tooltips is used, this controls the linewidth of the highlight stroke.
Default: 2
Name: exploded
Description: 
This can either be an array with the same number of elements as segments, or a single number, in which case every segment will be exploded that amount. If it's an array then only those segments will be exploded - eg [0,5,0,0]
Default: An empty array
Name: centerpin
Description: 
By using a centerpin you can add a circle to the center of your charts. This setting should be a number and is used as the radius of the centerpin.
Default: null
Name: centerpinStroke
Description: 
This is used as the stroke style of the centerpin.
Default: null
Name: centerpinFill
Description: 
This is used as the fill style of the centerpin.
Default: null
Name: clearto
Description: 
This is used in animations and effects as the default color to use when the canvas.
Default: null
Name: responsive
Description: 
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)
An accessor that you can use to retrieve the values of properties.

obj.set(name, value)
An accessor that you can use to set the values of properties.

obj.getShape(event)
This method makes it easy to get hold of which segment has been clicked on or hovered over. It returns an object which has the following indexes available:
object The chart object
x This is the center X coordinate for the segment.
y This is the center Y coordinate for the segment.
radius This is the radius of the segment.
angleStart This is the start angle of the segment. It's measured in radians - not degrees. 1 radian = 57.29 degrees.
angleEnd This is the end angle of the segment. It's measured in radians - not degrees. 1 radian = 57.29 degrees.
dataset Since Pie charts can only have one dataset this is always zero.
index The zero-indexed index of the segment on the chart.
sequentialIndex The sequentialIndex is the zero-indexed sequential index of the point on the chart. Since, with Pie charts, there's only ever a single dataset this is always the same as the index value.
tooltip If a tooltip is associated with this segment this will be it. id: strings are expanded for you (where the tooltip text is retrieved from the html tag with the matching ID).
<script>
    pie.canvas.onclick = function (e)
    {
        RGraph.redraw();
    
        var canvas  = e.target,
            obj     = canvas.__object__,
            shape   = obj.getShape(e);

        if (shape) {
            
            var x      = shape.x,
                y      = shape.y,
                radius = shape.radius,
                start  = shape.angleStart,
                end    = shape.angleEnd;

            obj.path(
                'b m % % a % % % % % false c s black f red',
                x, y, x, y, radius, start, end
            );
        }
    }
</script>

obj.explode(index, size)

The explode function allows you to programmatically trigger the exploding (ie the highlighting of) a particular segment. The explode method is used like so:

<script>
    pie = new RGraph.Pie({
        id: 'cvs',
        data: [8,9,4,6],
        options: {
        }
    }).draw();

    pie.explode(index, size);
</script>

The index argument is the zero-indexed segment to operate on (counting from the north axis). And the size is measured in pixels.


obj.getAngle(value)

This method can be used to get an appropriate angle for a value using the "scale" of the Pie chart. So if your Pie chart is showing values that go from 0-100 and your requested value is 50, this method will return an angle for the bottom of the Pie chart (ie halfway around).

obj.on(event, function)

This method can be used to set an event listener on an object. It operates similarly to the jquery on function. The first argument is the event that you wish to attach to and the second is the handler function. For example:

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

The function is useful if you use method chaining when creating your charts:

new RGraph.Pie({
    id: 'cvs',
    data: [4,5,3,8,6,3],
    options: {
    }
}).on('draw', function (obj)

    // Put your draw event code here

}).on('click', function (e, shape)
{
    // Put your click event code here
}).draw()

obj.exec(function)

The exec function is documented 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.

The Horseshoe meter

The Horseshoe meter is now (as of version 5.28) its own chart type and you can read about it on the Horseshoe meter documentation page.

The Segmented donut

The Segmented donut is now (as of version 5.28) its own chart type and you can read about it on the Segmented donut documentation page.

The Activity meter

The CActivity meter is now (as of version 5.28) its own chart type and you can read about it on the Activity meter documentation page.

The RadialProgress meter

The Radial Progress can be achieved by using the Activity meter class and configuring it as shown on the Activity meter documentation page.

Events

RGraph supports custom events that allow you to easily add interactivity to your charts if required. The following events are available:

For example:
new RGraph.Pie({
    id: 'cvs',
    data: [4,8,6],
    options: {
    }
}).on('draw', function (obj)
{
    console.log('The draw event has fired');
    
}).draw();

Effects

These effects are available and can be used instead of the draw function. There are also generic effects available which you can see here: Generic effects and transitions
<script>
    //
    // Optional callback function that's called when the effect is complete
    //
    function myCallback (obj)
    {
        // ...
    }

    new RGraph.Pie({
        id: 'cvs',
        data: [8,6,6,5,3,4,2],
        options: {
        }
    }).grow({frames: 60}, myCallback)
    // .implode({frames: 60}, myCallback)
    // .roundRobin({frames: 60}, myCallback)
    // .roundRobinSequential({frames: 90}, myCallback)
</script>