Rose charts documentation


 

Example

<script>
    $(document).ready(function ()
    {
        var data = [41,37,32,35,36];
        
        // To show a stacked Rose chart you specify the data like this. non-equi-angular
        // Rose charts are very similar to this but with only two elements to
        // each array - the magnitude of the segment and the (relative) size of the angle.
        // var rose = new RGraph.Rose({id: 'cvs', data: [[4,5], [6,8], [4,3]], ...
    
        // Create the rose chart.
        var rose = new RGraph.Rose({
            id: 'cvs',
            data: data,
            options: {
                labels: ['MSIE 7 (41%)', 'MSIE 6 (37%)', 'Firefox (16%)', 'Safari (3%)', 'Other (3%)'],
                margin: 3,
                textSize: 16
            }
        }).draw()
    })
</script>

The example file is here.

 

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.

 

Background

backgroundGridRadials
To control the number of "spokes" that the background grd has you can use this property.
Default: null

backgroundGridAxes
This controls whether the axes are shown.
Default: null

backgroundGridCount
An alternative to the above option - you can, instead of giving the spacing, use this option to specify the exact number of background circles.
Default: null

backgroundGridColor
The color of the background grid
Default: #ccc

backgroundAxes
Whether the axes should be shown or not.
Default: true

backgroundAxesColor
The color of the background axes.
Default: black

 

Chart configuration

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

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

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

anglesStart
If you want the chart to start at an angle other than the north axis - you can use this. (keep in mind that this is specified in RADIANS)
Default: 0

 

Margins

gutterLeft
The left gutter of the chart, (the gutter is where the labels and title are)).
Default: 25

gutterRight
The right gutter of the chart, (the gutter is where the labels and title are).
Default: 25

gutterTop
The top gutter of the chart, (the gutter is where the labels and title are).
Default: 25

gutterBottom
The bottom gutter of the chart, (the gutter is where the labels and title are).
Default: 25

margin
This is the margin that is either side of each segment. This allows you to have a gap between each segment. It is the size of the gap in degrees. It doesn't apply to non-equi-angular Rose charts - only regular and stacked charts.
Default: 0

 

Colors

colors
An array of colors to be used by the chart.
Default: ['red', 'rgb(0,255,255)', 'rgb(0,255,0)', 'gray', 'blue', 'rgb(255,128,255)','green', 'pink', 'gray', 'aqua']

colorsAlpha
Instead of using rgba(), you can use color definitions such as red along with this setting to add transparency.
Default: null

colorsSequential
Because of the new (as of July 2011) support for grouped Rose charts, the way colors are used has changed. So to have them used in a sequential fashion as before the change, you will need to set this option to true.
Default: false

 

Labels and text

textFont
The font used to render the text.
Default: Arial

textColor
The color of the labels.
Default: black

textSize
The size of the text (in points).
Default: 10

textSizeScale
If you want to specify a different text size for the scale you can do so with this property.
Default: null

labels
The labels, if any, for the chart.
Default: none

labelsAxes
This controls the axes that show the scale labels. Each letter stands for the appropriate axis (North, South, East and West)
Default: nsew

labelsPosition
This can be either center or edge and determines the position of the labels.
Default: center

labelsCount
This determines the number of labels that are displayed on the axes.
Default: 5

labelsBoxed
This determines whther the labels that are displayed on the axes are boxed or not.
Default: true

 

Titles

title
The title of the chart.
Default: none

titleFont
The font that the title is rendered in. If not specified the text.font setting is used (usually Arial)
Default: null

titleSize
The size of the title. If not specified the size is usually 2pt bigger than the text.size setting.
Default: null

titleBold
Whether the title is bold or not.
Default: true

titleBackground
The background color (if any) for the title.
Default: null

titleColor
The color of the title.
Default: black

titleX
To give the exact X coordinate for the title - use this
Default: null

titleY
To give the exact Y coordinate for the title - use this
Default: null

 

Axis properties

ymax
This can be set to control the maximum value of the scale. It's so called to maintain a degree of API compatibility across chart libraries.
Default: null

 

Scale

scaleRound
Whether to round the maximum scale value up or not. This will produce slightly better scales in some instances.
Default: null

scalePoint
The character used as the decimal point.
Default: .

scaleThousand
The character used as the thousand separator
Default: ,

scaleDecimals
This stipulates how many decimal places there are.
Default: 0

 

Key

key
An array of key information.
Default: An empty array

keyBackground
The color of the key background. Typically white, you could set this to something like rgba(255,255,255,0.7) to allow people to see things behind it.
Default: white

keyHalign
Instead of specifying the exact x/y coordinates, you can use this property to simply specify whether the key hould be aligned left or right.
Default: right

keyPosition
Determines the position of the key.Either graph (default), or gutter.
Default: graph

keyPositionX
This allows you to specify a specific X coordinate for the key.
Default: null

keyPositionY
This allows you to specify a specific Y coordinate for the key.
Default: null

keyPositionGutterBoxed
If you have the key in gutter mode (ie horizontal), this controls whether it has a border.
Default: true

keyPositionGraphBoxed
If you have the key in graph mode (ie a box), this controls whether it has a border.
Default: true

keyShadow
Whether a small drop shadow is applied to the key.
Default: false

keyShadowColor
The color of the shadow.
Default: #666

keyShadowBlur
The extent of the blurring effect used on the shadow.
Default: 3

keyShadowOffsetx
The X offset of the shadow.
Default: 2

keyShadowOffsety
The Y offset of the shadow.
Default: 2

keyRounded
This controls whether the corners of the key (in graph mode) are curved. If the key is gutter mode, this has no effect.
Default: false

keyColorShape
This can be square, circle or line and controls how the color indicators in the key appear.
Default: square

keyLinewidth
The line width of the surrounding border on the key.
Default: 1

keyColors
You can use this property to specifically set the colors to be used by the key.
Default: null

keyTextColor
This can be used to give the color of the text in the key. It can either be a single string or an array of colors.
Default: black

keyInteractive
By setting this to true you can make the key clickable - thus highlighting the chosen item
Default: false

keyInteractiveHighlightChartFill
Using this property you can set the color used to highlight when the interactive key is clicked
Default: rgba(255,255,255,0.7)

keyInteractiveHighlightChartStroke
Using this property you can set the color used to highlight when the interactive key is clicked
Default: black

keyInteractiveHighlightLabel
This is the color used to highlight the key label when using the interactive key
Default: rgba(255,0,0,0.2)

 

Interactive features

tooltips
A numerically indexed array of tooltips that are shown when a bar is clicked. These can contain HTML.
Default: An empty array

tooltipsEvent
This is the event that triggers the tooltips. It can be either onclick or onmousemove.
Default: onclick

tooltipsEffect
The effect used for showing tooltips. Can be either fade or none.
Default: fade

tooltipsCssClass
This is the name of the CSS class the chart uses.
Default: RGraph_tooltip

tooltipsOverride
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

tooltipsCoordsPage
If set to true the tooltips will be positioned using the .pageX and .pageY coordinates. If you use canvas tags that are offset from the .pageX and .pageY coordinates - this can help with tooltip positioning.
Default: false

contextmenu
An array of context menu items. More information on context menus is here.
Default: [] (An empty array)

annotatable
Whether annotations are enabled for the chart (ie you can draw on the chart interactively.
Default: false

annotateColor
If you do not allow the use of the palette, then this will be the only colour allowed for annotations.
Default: black

annotateLinewidth
This is the line width of the annotations.
Default: 1

resizable
Defaulting to false, this determines whether your chart will be resizable. Because of the numerous event handlers this has to install code on, This feature is unlikely to work with other dynamic features (the context menu is fine however).
Default: false

resizeHandleBackground
With this you can specify the background color for the resize handle. If you're adjusting the position of the handle then you may need this to make the handle stand out more.
Default: null

adjustable
Defaulting to false, this determines whether your bar chart will be adjustable.
Default: false

 

Zoom

zoomFactor
This is the factor that the chart will be zoomed by (bigger values means more zoom)
Default: 1.5

zoomFadeIn
Whether the zoomed canvas fades in or not. This also can be used to control the fade in for the zoom in thumbnail mode.
Default: true

zoomFadeOut
Whether the zoomed canvas fades out or not. This also can be used to control the fade in for the zoom in thumbnail mode.
Default: true

zoomHdir
The horizontal direction of the zoom. Possible values are: left, center, right
Default: right

zoomVdir
The vertical direction of the zoom. Possible values are: up, center, down
Default: down

zoomDelay
The delay (in milliseconds) between frames.
Default: 50

zoomFrames
The number of frames in the zoom animation.
Default: 10

zoomShadow
Whether or not the zoomed canvas has a shadow or not.
Default: true

 

Events

eventsClick
If you want to add your own onclick function you can do so by assigning it to this property. See here for details.
Default: null

eventsMousemove
If you want to add your own onmousemove function you can do so by assigning it to this property. See here for details.
Default: null

 

Miscellaneous

highlightStroke
If you use tooltips, this controls the colour of the highlight stroke.
Default: black

highlightFill
If you use tooltips, this controls the colour of the highlight fill.
Default: rgba(255,255,255,0.5)

variant
This option can be either stacked (the default) or non-equi-angular. Just because this option is set to stacked does not automatically mean your chart is stacked. If you don't suppy the appropriate data you chart may well appear as a regular Rose chart. Examples of appropriate data:

A regular Rose chart

myRose = new RGraph.Rose('cvs', [8,5,4,8,6,7,2,3,5,8]);

A stacked Rose chart

myRose = new RGraph.Rose('cvs', [[2,6],[2,4],[1,5],[4,3],[7,5],[8,3],[4,5],[3,4],[2,6],[4,5]]);

A non-equi-angular Rose chart

var myRose = new RGraph.Rose({
    id: 'cvs',
    data: [[45,23],[45,23],[5,26],[78,4],[49,12],[49,21],[40,18],[48,12],[43,23],[45,12]],
    options: {
        variant: 'non-equi-angular'
    }
}).draw();

It is important to note that with a non-equi-angular each "value" is actually an array consisting of two values, as shown. The first value represents the magnitude of the segment (ie how far the segment extends outwards), and the second value represents the size of the segment. The second value is relative to all the other second values - it is not the absolute angle used. The angle is calculated for you.


Default: stacked

exploded
This stipulates the exploded value for a segment. It can either be a number which is applied to all segments, or an array of seperate values (eg [15,0,20,25]). The values are the distance from the center that the segment is.
Default: 0

clearto
This is used in animations and effects as the default color to use when the canvas.
Default: null

segmentHighlight
If you wish you can have segments of the chart highlight as you move the mouse around.
Default: false

segmentHighlightCount
The number of segments by default corresponds to the number of "radials" that the background grid has but using this property you can set it explicitly.
Default: null

segmentHighlightFill
The fill color of the highlight
Default: rgba(0,255,0,0.5)

segmentHighlightStroke
The stroke color of the highlight
Default: rgba(0,0,0,0)

 

Methods

 

obj.get(name)
An accessor that you can use to retrieve the value of properties.

 

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

obj.getShape(event)

obj.getShape() makes it easy to determine which segment of the Rose chart was clicked on. It provides:

The shape also includes textual indexes like this: shape['object'] And they are:

<script>
    RGraph.register(myGraph);
    
    myGraph.canvas.onclick = function (e)
    {
        RGraph.fixEventObject(e);
        RGraph.redraw();

        var ca  = e.target;
        var co  = ca.getContext('2d');
        var obj = ca.__object__;
        var segment = obj.getShape(e);
        
        if (segment) {
            co.fillStyle = 'rgba(255,255,255,0.5)';
            co.beginPath();            
                co.moveTo(segment[0], segment[1]);
                co.arc(segment[0], segment[1], segment[3], segment[4], segment[5], 0);
                co.arc(segment[0], segment[1], segment[2], segment[5], segment[4], true);
            co.stroke();
            co.fill();
            
            e.stopPropagation();
        }
    }
    
    window.onclick = function (e)
    {
        RGraph.redraw();
    }
</script>
Important Note

This method was formerly a common object method, called RGraph.getSegment(e), but has now (6th March 2011) been moved to be part of the Rose chart object.

 

obj.getRadius(value)

This method can be used to get the relevant radius for a given scale value.

 

obj.on(event, func)

This method can be used to set an event listener on an object. It operates in a similar way to the jQuery .on() function - the first argument is the event you wish to attach to and the second is the handler function. For example:

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

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

var obj = new RGraph.Rose({
    id: 'cvs',
    data: [4,8,6,3,5,8,4,6]
}).on('draw', function (e, shape)
{
    // Put ondraw code here
}).on('click', function (e, shape)
{
    // Handle click event
}).draw();

 

Stacked Rose charts

Rose charts can now be stacked, much like stacked Bar charts. For an example see this Rose chart demo page. The data should be supplied in the same format as a stacked Bar chart:

<script>
    rose = new RGraph.Rose({
        id: 'cvs',
        data: [[4,6,2],[8,4,7],[4,3,6],[1,5,6]],
        options: {
        }
    }).draw();
</script>

 

 

Non-equi-angular Rose charts

Rose charts can be displayed in a non-equi-angular mode. For an example see this Rose chart demo page. Instead of a plain array of values (as with a regular Rose chart), each data point should itself be a two element array consisting of the magnitude value and also a relative circular size. This second value is not the actual size of the angle - this is calculated. For example:

You can use these properties to control how the Waterfall chart apears. You can set them by including them in the options section of the configuration as above.
<script>
    rose = new RGraph.Rose({
        id: 'cvs',
        data: [[47,6],[48,2],[40,4],[43,5],[45,6]],
        options: {
            variant: 'non-equi-angular'
        }
    }).draw();
</script>

 

Animation 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)
    {
        // ...
    }

    var obj = new RGraph.Rose({
        id: 'cvs',
        data: [8,6,3,5,2,4,8],
        options: {
            gutterLeft: 35
        }
    }).grow({frames: 60}, myCallback)
    // .roundRobin({frames: 60}, myCallback)
    // .implode({frames: 60}, myCallback)
    // .explode({frames: 60}, myCallback)
</script>