SVG Rose charts API reference

Documentation about the SVG Rose chart including information about all of the options and methods that are available to you.

 

Example

The code below produces a chart like this:

<script>
    // This is the data for the Rose chart
    var data = [
        [8,6,9], [4,8,5], [6,2,11], [8,5,3],
        [2,4,3], [8,6,4], [4,4,9], [4,8,9],
        [7,3,2], [8,4,6], [4,8,6], [7,5,9]
    ];

    var rose = new RGraph.SVG.Rose({
        id: 'chart-container',
        data: data,
        options: {
            scaleUnitsPost: 'j',
            backgroundGridColor: '#aaa',
            backgroundGridRadialsCount: 0,
            tooltips: [
                'Richard','Fred','Gloria',
                'Richard','Fred','Gloria',
                'Richard','Fred','Gloria',
                'Richard','Fred','Gloria',
                'Richard','Fred','Gloria',
                'Richard','Fred','Gloria',
                'Richard','Fred','Gloria',
                'Richard','Fred','Gloria',
                'Richard','Fred','Gloria',
                'Richard','Fred','Gloria',
                'Richard','Fred','Gloria',
                'Richard','Fred','Gloria'
            ],
            marginTop: 50,
            colors: ['#faa', '#afa', '#aaf'],
            colorsOpacity: 0.75,
            colorsStroke: 'rgba(0,0,0,0)',
            labels: ['Jan','Feb', 'Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
            labelsRadialMargin: 20,
            exploded: 2
        }
    }).draw();

    // Custom CSS for the tooltips
    RGraph.SVG.tooltips.style.backgroundColor = 'black';
    RGraph.SVG.tooltips.style.color           = 'white';
    RGraph.SVG.tooltips.style.boxShadow       = '';
    RGraph.SVG.tooltips.style.fontWeight      = 'bold';
</script>

 

Types of Rose charts

There are four main types of Rose chart available:

 

The angles and angles2 properties

Formerly this array contained details of the segment. However as of version 5 this has now changed so that the only element is one called element. This is a reference to the SVG path element which has various data-attributes set on it which can give you the details of the segment. These data attributes are:

The difference between the angles and angles2 arrays is how they're indexed. So with a stacked chart that has four stacks and 3 segments per stack the obj.coords array would be arranged like this:

The coordinates are appended to the array. The obj.coords2 on the other hand is arranged two dimensionally:

 

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 above.

Chart configuration properties

PropertyDescriptionDefault
centerxIf required, you can position the Rose chart using this instead of the margins.null
centeryIf required, you can position the Rose chart using this instead of the margins.null
radiusIf required, you can size the Rose chart using this instead of the margins.null
centerx
If required, you can position the Rose chart using this instead of the margins.
Default: null

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

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

Background properties

PropertyDescriptionDefault
backgroundGridWhether the background grid is displayed or not.true
backgroundGridColorThe color of the background grid.#ddd
backgroundGridRadialsCountThe number of lines that emanate from the center outwards. Set this to zero to disable them. By default the amount is matched to the number of data pieces that you have.null
backgroundGridConcentricsCountThe number of concentric background grid circles that are displayed.5
backgroundGridLinewidthThe linewidth of the background grid lines.1
backgroundGridRadialsAngleOffsetThis is the angular offset that's applied to the background grid radials (that emanate from the center outwards). It's measured in radians.0
backgroundGrid
Whether the background grid is displayed or not.
Default: true

backgroundGridColor
The color of the background grid.
Default: #ddd

backgroundGridRadialsCount
The number of lines that emanate from the center outwards. Set this to zero to disable them. By default the amount is matched to the number of data pieces that you have.
Default: null

backgroundGridConcentricsCount
The number of concentric background grid circles that are displayed.
Default: 5

backgroundGridLinewidth
The linewidth of the background grid lines.
Default: 1

backgroundGridRadialsAngleOffset
This is the angular offset that's applied to the background grid radials (that emanate from the center outwards). It's measured in radians.
Default: 0

Margin properties

PropertyDescriptionDefault
marginLeftThe left margin of the chart, (the margin is where the labels and title are)).35
marginRightThe right margin of the chart, (the margin is where the labels and title are).35
marginTopThe top margin of the chart, (the margin is where the labels and title are).35
marginBottomThe bottom margin of the chart, (the margin is where the labels and title are).35
amarginThis is the margin that's applied to each segment. So by increasing this value it results in making each segment thinner. It can be a number - in which case it's measured using radians (so use 0.01 for example) or it can be a string like this: 5deg in which case it's measured in degrees - so a setting of 5deg would usually be adequate.0
marginLeft
The left margin of the chart, (the margin is where the labels and title are)).
Default: 35

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

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

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

amargin
This is the margin that's applied to each segment. So by increasing this value it results in making each segment thinner. It can be a number - in which case it's measured using radians (so use 0.01 for example) or it can be a string like this: 5deg in which case it's measured in degrees - so a setting of 5deg would usually be adequate.
Default: 0

Color properties

PropertyDescriptionDefault
colorsColors to be used for the Rose segments.['red', 'black', 'orange', 'green', '#6ff', '#ccc', 'pink', 'orange', 'cyan', 'maroon', 'olive', 'teal']
colorsSequentialNormal color use is per stack/group (implementation to come as of April 2017) but if you want the colors used sequentially then set this to true.false
colorsOpacityThis is the opacity value that's applied to the colors of the segments.1
colorsStrokeThe color of the separating lines.white
colors
Colors to be used for the Rose segments.
Default: ['red', 'black', 'orange', 'green', '#6ff', '#ccc', 'pink', 'orange', 'cyan', 'maroon', 'olive', 'teal']

colorsSequential
Normal color use is per stack/group (implementation to come as of April 2017) but if you want the colors used sequentially then set this to true.
Default: false

colorsOpacity
This is the opacity value that's applied to the colors of the segments.
Default: 1

colorsStroke
The color of the separating lines.
Default: white

Labels and text properties

PropertyDescriptionDefault
textSizeThe size of the text.12
textFontThe font used to render the text.Arial, Verdana, sans-serif
textColorThe color of the labels.black
textItalicWhether the labels are italic or not.false
textBoldWhether the labels are bold or not.false
labelsAn array of the labels that are arranged in a circle around the Rose chart.[] (an empty array)
labelsFontThe font that the circular labels use.null
labelsSizeThe size of the circular labels.null
labelsColorThe color of the circular labels.null
labelsBoldWhether the circular labels are bold or not.null
labelsItalicWhether the circular labels are italic or not.null
labelsRadialMarginThe extra distance that, in addition to the radius, the labels are positioned.10
labelsAnglesOffsetIf you want to specify an offset angle for the labels (so you can move the labels around the chart) then this is the option to use. It's measured in radians.0
scaleVisibleWhether the scale is visible or not.true
scaleMaxThe maximum scale value. By default it's calculated for you.null
scaleMinThe minimum scale value.0
scaleFontThe font used to render the text in.null
scaleSizeThe size of the scale text.null
scaleBoldWhether the scale text is bold or not.null
scaleItalicWhether the scale text is italic or not.null
scaleColorThe color of the scale labels.null
scaleUnitsPreThe units that are added before each label.(an empty string)
scaleUnitsPostThe units that are added after each label.(an empty string)
scalePointThe character(s) that are used as the decimal point..
scaleThousandThe character(s) that are used as the thousand separator.,
scaleDecimalsThe number of decimals that are shown on the scale.0
scaleLabelsCountThe number of labels that are shown on the scale (not including the zero label).5
scaleFormatterThis can be a function that is passed the object and number as the arguments and should return the formatted number. This allows you to completely control the formatting used on the scale. For example:
scaleFormatter: function (obj, num)
{
},
null
textSize
The size of the text.
Default: 12

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

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

labels
An array of the labels that are arranged in a circle around the Rose chart.
Default: [] (an empty array)

labelsFont
The font that the circular labels use.
Default: null

labelsSize
The size of the circular labels.
Default: null

labelsColor
The color of the circular labels.
Default: null

labelsBold
Whether the circular labels are bold or not.
Default: null

labelsItalic
Whether the circular labels are italic or not.
Default: null

labelsRadialMargin
The extra distance that, in addition to the radius, the labels are positioned.
Default: 10

labelsAnglesOffset
If you want to specify an offset angle for the labels (so you can move the labels around the chart) then this is the option to use. It's measured in radians.
Default: 0

scaleVisible
Whether the scale is visible or not.
Default: true

scaleMax
The maximum scale value. By default it's calculated for you.
Default: null

scaleMin
The minimum scale value.
Default: 0

scaleFont
The font used to render the text in.
Default: null

scaleSize
The size of the scale text.
Default: null

scaleBold
Whether the scale text is bold or not.
Default: null

scaleItalic
Whether the scale text is italic or not.
Default: null

scaleColor
The color of the scale labels.
Default: null

scaleUnitsPre
The units that are added before each label.
Default: (an empty string)

scaleUnitsPost
The units that are added after each label.
Default: (an empty string)

scalePoint
The character(s) that are used as the decimal point.
Default: .

scaleThousand
The character(s) that are used as the thousand separator.
Default: ,

scaleDecimals
The number of decimals that are shown on the scale.
Default: 0

scaleLabelsCount
The number of labels that are shown on the scale (not including the zero label).
Default: 5

scaleFormatter
This can be a function that is passed the object and number as the arguments and should return the formatted number. This allows you to completely control the formatting used on the scale. For example:
scaleFormatter: function (obj, num)
{
},

Default: null

Title properties

PropertyDescriptionDefault
titleThe title of the chart.(An empty string)
titleXThe specific X coordinate of the title. This can also be a string that looks like this: "+10" or "-10" in which case it's added to the calculated position.null
titleYThe specific Y coordinate of the title. This can also be a string that looks like this: "+10" or "-10" in which case it's added to the calculated position.null
titleHalignThe horizontal alignment of the title.center
titleValignThe vertical alignment of the title.bottom
titleColorThe color of the title. It defaults to be the same as the textColor property.null
titleFontThe font used to render the title.null
titleSizeThe size of the font used to render the title. It defaults to be a little larger than the textSize property.null
titleBoldWhether the title is bold or not.null
titleItalicWhether the title is italic or not.null
titleSubtitleThe subtitle of the chart. If a subtitle is specified the title is moved up to accommodate it. As such you might need to give a larger marginTop value.(An empty string)
titleSubtitleXThe specific X coordinate of the subtitle. This can also be a string that looks like this: "+10" or "-10" in which case it's added to the calculated position.null
titleSubtitleYThe specific Y coordinate of the subtitle. This can also be a string that looks like this: "+10" or "-10" in which case it's added to the calculated position.null
titleSubtitleHalignThe horizontal alignment of the subtitle.center
titleSubtitleValignThe vertical alignment of the subtitle.top
titleSubtitleColorThe color of the subtitle.#aaa
titleSubtitleFontThe font used to render the subtitle.null
titleSubtitleSizeThe size of the font used to render the subtitle. It defaults to be slightly smaller than the textSize setting.null
titleSubtitleBoldWhether the subtitle is bold or not.null
titleSubtitleItalicWhether the subtitle is italic or not.null
title
The title of the chart.
Default: (An empty string)

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

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

titleHalign
The horizontal alignment of the title.
Default: center

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

titleSubtitleX
The specific X coordinate of the subtitle. 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

titleSubtitleY
The specific Y coordinate of the subtitle. 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

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 slightly smaller than the textSize setting.
Default: null

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

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

Key properties

PropertyDescriptionDefault
keyAn array of the labels that appear on the key.null
keyColorsAn array of colors to be shown on the key. If not specified then the colors option will be used instead.null
keyLabelsColorThe color of the text in the key.null
keyLabelsBoldWhether the key text is bold or not.null
keyLabelsFontThe font to use for the key text.null
keyLabelsSizeThe size to use for the key text.null
ketLabelsItalicWhether the key text is italic or not.null
keyLabelsOffsetxThe horizontal pixel offset of the key text (just the text).0
keyLabelsOffsetyThe vertical pixel offset of the key text (just the text).-1
keyOffsetxThe horizontal pixel offset of the entire key.0
keyOffsetyThe horizontal pixel offset of the entire key.0
keyColorShapeThis controls which shape should be displayed on the key. It can be a string or an array of strings. The possible options are: rect circle triangle line dot rectdotrect
key
An array of the labels that appear on the key.
Default: null

keyColors
An array of colors to be shown on the key. If not specified then the colors option will be used instead.
Default: null

keyLabelsColor
The color of the text in the key.
Default: null

keyLabelsBold
Whether the key text is bold or not.
Default: null

keyLabelsFont
The font to use for the key text.
Default: null

keyLabelsSize
The size to use for the key text.
Default: null

ketLabelsItalic
Whether the key text is italic or not.
Default: null

keyLabelsOffsetx
The horizontal pixel offset of the key text (just the text).
Default: 0

keyLabelsOffsety
The vertical pixel offset of the key text (just the text).
Default: -1

keyOffsetx
The horizontal pixel offset of the entire key.
Default: 0

keyOffsety
The horizontal pixel offset of the entire key.
Default: 0

keyColorShape
This controls which shape should be displayed on the key. It can be a string or an array of strings. The possible options are: rect circle triangle line dot rectdot
Default: rect

Tooltip properties

PropertyDescriptionDefault
tooltipsAn array of tooltips for the chart. This array should NOT be multidimensional - even for stacked or grouped charts.null
tooltipsOverrideIf required, this can be a function that totally handles the tooltip showing instead of the default RGraph tooltips. It should look like this:
tooltipsOverride: function (obj, opt)
{
    // Show tooltip
}
The opt is an argument that contains these items:
  • object The chart object.
  • index The index of the element (that triggered the tooltip).
  • sequentialIndex The sequential index of the element that was clicked.
  • text The text to be used as the tooltip. Remember that this may contain HTML (or whatever else you may have specified).
  • event The event object (either a click or mousemove event).
null
tooltipsCssClassThe CSS class that's applied to the tooltip DIV.RGraph_tooltip
tooltipsEventThe event used for tooltips (either click or mousemove.click
tooltips
An array 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 that's applied to the tooltip DIV.
Default: RGraph_tooltip

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

Highlight properties

PropertyDescriptionDefault
highlightStrokeThe color of the stroke of the highlight.rgba(0,0,0,0)
highlightFillThe color of the fill of the highlight.rgba(255,255,255,0.7)
highlightLinewidthThe linewidth of the stroke of the highlight.1
highlightStroke
The color of the stroke of the highlight.
Default: rgba(0,0,0,0)

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

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

Other properties

PropertyDescriptionDefault
linewidthThe linewidth of the separating lines.1
explodedThis can either be a number or an array and controls by how much the segments are exploded.0
segmentsAngleOffsetThis is the angular offset that affects the segments. It's measured in radians.0
variantThis can be normal or non-equi-angular and determines what type of chart will be shown. The stacked variations of each type are triggered by using arrays of numbers instead of just regular numbers.regular
linewidth
The linewidth of the separating lines.
Default: 1

exploded
This can either be a number or an array and controls by how much the segments are exploded.
Default: 0

segmentsAngleOffset
This is the angular offset that affects the segments. It's measured in radians.
Default: 0

variant
This can be normal or non-equi-angular and determines what type of chart will be shown. The stacked variations of each type are triggered by using arrays of numbers instead of just regular numbers.
Default: regular

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 configuration properties or change them.

 

obj.on(event, handler)

This function adds an event listener (such as beforedraw or draw) 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)

Effects

There are two effects that are available to you. These effects work with all of the modes of operation that the Rose chart has:

The demo pages are: