SVG Rose charts API reference

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

 

Example

The code below produces a chart like this:

<script>
        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]
        ];
        
        // data = [4,8,6,9,5,2,8,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'
                ],
                gutterTop: 50,
                colors: ['#faa', '#afa', '#aaf'],
                colorsOpacity: 0.75,
                strokestyle: 'rgba(0,0,0,0)',
                exploded: 5,
                labels: [
                    'Rich','Joel', 'Kev', 'Gary',
                    'Gerry', 'Deb','Fliss','Val',
                    'Lou','Ken','Gary','Matt'
                ],
                labelsRadialMargin: 20
            }
        }).draw();

        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

The angles for the segments on the Rose chart are held in the obj.angles and obj.angles2 arrays. It's similar to that of the Pie chart except that for some segments (ie in a stacked Rose chart variant) there will be an radius-inner property. Each element in this array is an object that has the following properties:

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:

Simply - the coordinates are simply appened 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 apears. You can set them by including them in the options section of the configuration as above.

Chart configuration

PropertyDescriptionDefault
centerxIf required, you can position the Rose chart using this instead of the gutters.null
centeryIf required, you can position the Rose chart using this instead of the gutters.null
radiusIf required, you can size the Rose chart using this instead of the gutters.null

Background

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 thats applied to the background grid radials (that emanate from the center outwards). Its measured in radians.0

Margins

PropertyDescriptionDefault
gutterLeftThe left gutter of the chart, (the gutter is where the labels and title are)).35
gutterRightThe right gutter of the chart, (the gutter is where the labels and title are).35
gutterTopThe top gutter of the chart, (the gutter is where the labels and title are).35
gutterBottomThe bottom gutter of the chart, (the gutter is where the labels and title are).35
marginThis 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 its measured in degrees - so a setting of 5deg would usually be adequate.0

Colors

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 thats applied to the colors of the segments.1
strokestyleThe color of the seperating lines.white

Labels and text

PropertyDescriptionDefault
textSizeThe size of the text.12
textFontThe font used to render the text.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. It defaults to the textFont settingnull
labelsSizeThe size of the circular labels. It defaults to be 4 points greater than the textSize setting.null
labelsColorThe color of the circular labels. It defaults to the textColor setting.null
labelsBoldWhether the circular labels are bold or not. It defaults to the textBold setting.null
labelsItalicWhether the circular labels are italic or not. It defaults to the textItalic setting.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. Its measured in radians.0
scaleVisibleWhether the scale is visible or not.true
scaleMaxThe maximum scale value. By default its calculated for you.null
scaleMinThe minimum scale value.0
scaleFontThe font used to render the text in. It defaults to the textFont setting.null
scaleSizeThe size of the scale text. It defaults to the textSize setting.null
scaleBoldWhether the scale text is bold or not. It defaults to the textBold setting.null
scaleItalicWhether the scale text is italic or not. It defaults to the textItalic setting.null
scaleColorThe color of the scale labels. It defaults to the textColor setting.null
scaleUnitsPreThe units that are added BEFORE each label.(an empty string)
scaleUnitsPostThe units that are added AFTER each label.(an empty string)
scalePointThe chracter(s) that are used as the decimal point..
scaleThousandThe chracter(s) that are used as the thousand sperator.,
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

Title

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 propertynull
titleBoldWhether the title is bold or not.false
titleItalicWhether the title is italic or not.false
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 gutterTop 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 the same as the textSize setting.null
titleBoldWhether the subtitle is bold or not.false
titleSubtitleItalicWhether the subtitle is italic or not.false

Key

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
keyTextBoldWhether the key text is bold or not.false
keyTextFontThe font to use for the key text. If not specified it defaults to the textFont setting.null
keyTextSizeThe size to use for the key text. If not specified then the textSize is used.null
ketTextItalicWhether the key text is italic or not.false
keyTextOffsetxThe horizontal pixel offset of the key text (just the text).0
keyTextOffsetyThe 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

Tooltips

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 thats applied to the tooltip DIV.RGraph_tooltip
tooltipsEventThe event used for tooltips (either click or mousemove.click

Highlight

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

Other

PropertyDescriptionDefault
linewidthThe linewidth of the seperating 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. Its 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 ype are triggered by using arrays of numbers instead of just regular numbers.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 parameters or change them.

 

obj.on(event, handler)

This function adds an event listener (such as onbeforedraw or ondraw) to the chart object.

 

obj.exec(func)

This function simply executes the function that you give it (there and then - not on any particular event)