Rose charts documentation

Share RGraph:  

 

Example

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

Layout style:     
  

Background

PropertyDescriptionDefault
backgroundGridRadialsTo control the number of "spokes" that the background grd has you can use this property.null
backgroundGridAxesThis controls whether the axes are shown.null
backgroundGridCountAn alternative to the above option - you can, instead of giving the spacing, use this option to specify the exact number of background circles.null
backgroundGridColorThe color of the background grid#ccc
backgroundAxesWhether the axes should be shown or not.true
backgroundAxesColorThe color of the background axes.black

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
anglesStartIf 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)0

Margins

PropertyDescriptionDefault
gutterLeftThe left gutter of the chart, (the gutter is where the labels and title are)).25
gutterRightThe right gutter of the chart, (the gutter is where the labels and title are).25
gutterTopThe top gutter of the chart, (the gutter is where the labels and title are).25
gutterBottomThe bottom gutter of the chart, (the gutter is where the labels and title are).25
marginThis 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.0

Shadow

PropertyDescriptionDefault
shadowWhether the shadow is enabled or not.false
shadowColorThe color of the shadow#aaa
shadowOffsetxThe X offset of the shadow0
shadowOffsetyThe Y offset of the shadow0
shadowBlurThe magnitude of the shadow blurring effect.15

Labels and text

PropertyDescriptionDefault
textAccessibleA new feature in 2016 that allows you to use DOM text in place of canvas text. It makes for much 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>
true
textAccessibleOverflowThis 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 gutters if you wish.visible
textAccessiblePointereventsThis controls whether the DOM text responds to mouse based events or not (it sets the pointer-events CSS property to none).true
textFontThe font used to render the text.Arial
textColorThe color of the labels.black
textSizeThe size of the text (in points).10
textSizeScaleIf you want to specify a different text size for the scale you can do so with this property.null
labelsThe labels, if any, for the chart.none
labelsColorThe color of the labelsnull (same as textColor)
labelsAxesThis controls the axes that show the scale labels. Each letter stands for the appropriate axis (North, South, East and West)nsew
labelsPositionThis can be either center or edge and determines the position of the labels.center
labelsCountThis determines the number of labels that are displayed on the axes.5
labelsBoxedThis determines whther the labels that are displayed on the axes are boxed or not.true

Titles

PropertyDescriptionDefault
titleThe title of the chart.none
titleFontThe font that the title is rendered in. If not specified the text.font setting is used (usually Arial)null
titleSizeThe size of the title. If not specified the size is usually 2pt bigger than the text.size setting.null
titleBoldWhether the title is bold or not.true
titleItalicWhether the title is italic or not.false
titleBackgroundThe background color (if any) for the title.null
titleColorThe color of the title.black
titleXTo give the exact X coordinate for the title - use thisnull
titleYTo give the exact Y coordinate for the title - use thisnull

Axis properties

PropertyDescriptionDefault
ymaxThis 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.null

Scale

PropertyDescriptionDefault
scaleRoundWhether to round the maximum scale value up or not. This will produce slightly better scales in some instances.null
scalePointThe character used as the decimal point..
scaleThousandThe character used as the thousand separator,
scaleDecimalsThis stipulates how many decimal places there are.0

Key

The key properties are documented on the key documentation page.

Interactive features

PropertyDescriptionDefault
tooltipsA numerically indexed array of tooltips that are shown when a bar is clicked. These can contain HTML.An empty array
tooltipsEventThis is the event that triggers the tooltips. It can be either onclick or onmousemove.onclick
tooltipsEffectThe effect used for showing tooltips. Can be either fade or none.fade
tooltipsCssClassThis is the name of the CSS class the chart uses.RGraph_tooltip
tooltipsOverrideIf 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 pagenull
tooltipsNohideonclearNot an option that you'll need particularly often if at all. Setting this to true means that when you call the RGraph.clear() API function tooltip DO NOT get hidden.false
contextmenuAn array of context menu items. More information on context menus is here.[] (An empty array)
annotatableWhether annotations are enabled for the chart (ie you can draw on the chart interactively.false
annotateColorIf you do not allow the use of the palette, then this will be the only colour allowed for annotations.black
annotateLinewidthThis is the line width of the annotations.1
resizableDefaulting 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).false
resizeHandleBackgroundWith 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.null
resizableMinwidthThis allows you to set a minimum width that the chart can be resized to.null
resizableMinheightThis allows you to set a minimum height that the chart can be resized to.null
resizableMaxwidthThis allows you to set a maximum width that the chart can be resized to.null
resizableMaxheightThis allows you to set a maximum height that the chart can be resized to.null
adjustableDefaulting to false, this determines whether your bar chart will be adjustable.false

Zoom

PropertyDescriptionDefault
zoomFactorThis is the factor that the chart will be zoomed by (bigger values means more zoom)1.5
zoomFadeInWhether the zoomed canvas fades in or not. This also can be used to control the fade in for the zoom in thumbnail mode.true
zoomFadeOutWhether the zoomed canvas fades out or not. This also can be used to control the fade in for the zoom in thumbnail mode.true
zoomHdirThe horizontal direction of the zoom. Possible values are: left, center, rightright
zoomVdirThe vertical direction of the zoom. Possible values are: up, center, downdown
zoomDelayThe delay (in milliseconds) between frames.50
zoomFramesThe number of frames in the zoom animation.10
zoomShadowWhether or not the zoomed canvas has a shadow or not.true

Events

PropertyDescriptionDefault
eventsClickIf you want to add your own onclick function you can do so by assigning it to this property. See here for details.null
eventsMousemoveIf you want to add your own onmousemove function you can do so by assigning it to this property. See here for details.null
eventsMouseoverIf you want to add your own onmouseover function you can do so by assigning it to this property. See here for details.null
eventsMouseoutIf you want to add your own onmouseout function you can do so by assigning it to this property. See here for details.null

Miscellaneous

PropertyDescriptionDefault
highlightStyleBy default this is null but you can set it to a function if you wish so that function is called to do the chart highlighting. Its passed the shape object as an argument.null
highlightStrokeIf you use tooltips, this controls the colour of the highlight stroke.black
highlightFillIf you use tooltips, this controls the colour of the highlight fill.rgba(255,255,255,0.5)
variantThis 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

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

A stacked Rose chart

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

A non-equi-angular Rose chart

var rose = 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'
        //variant: 'non-equi-angular3d'
    }
}).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.

stacked
variantThreedDepthThis is the depth/thickness of the Rose chart when in 3D mode. Using larger depths can make the labels be drawn over the labels.10
explodedThis 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.0
cleartoThis is used in animations and effects as the default color to use when the canvas.null
segmentHighlightIf you wish you can have segments of the chart highlight as you move the mouse around.false
segmentHighlightCountThe 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.null
segmentHighlightFillThe fill color of the highlightrgba(0,255,0,0.5)
segmentHighlightStrokeThe stroke color of the highlightrgba(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();

 

The exec option and method

The exec function is documented here.

 

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>