SVG Radar charts API reference

  Read comments...

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

 

Example

<script>
    // Some data that is to be shown on the Pie chart. For multiple
    lines it can also be an array of arrays
    var data = [180,45,133,152,278,221,56];

    new RGraph.SVG.Radar({
        id: 'chart-container',
        data: data,
        options: {
        }
    }).draw();
</script>

The code above produces a chart like this:

 

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

Properties: centerx, centery, radius

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

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

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

 

Margins

Properties: gutterLeft, gutterRight, gutterTop, gutterBottom

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

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

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

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

 

Background

Properties: backgroundGrid, backgroundGridColor, backgroundGridRadialsCount, backgroundGridConcentricsCount, backgroundGridLinewidth

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 eminating from the center of the Radar chart outwards.
Default: null (linked to how many data points that you have)

backgroundGridConcentricsCount
The number of lines that go around the center of the radar chart.
Default: 5

backgroundGridLinewidth
The linewidth that is used to draw the background grid.
Default: 1

 

Colors

Properties: colors, filled, filledOpacity, filledAccumulative

colors
Colors to be used for the pie segments.
Default: ['red', 'black', 'orange', 'green', '#6ff', '#ccc', 'pink', 'orange', 'cyan', 'maroon', 'olive', 'teal']

filled
Whether the Radar chart is filed or not.
Default: false

filledOpacity
The opacity of the fill in Radar charts
Default: 0.25

filledAccumulative
If true that datasets will be stacked on top of each other.
Default: true

 

Text

Properties: textSize, textFont, textColor, textItalic, textBold, labels

textSize
The size of the text.
Default: 12

textFont
The font used to render the text.
Default: 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 labels for the chart.
Default: []

 

Shadow

Properties: shadow, shadowOffsetx, shadowOffsety, shadowBlur, shadowOpacity

shadow
Whether or not the chart has a shadow or not.
Default: false

shadowOffsetx
The X offset of the shadow.
Default: 2

shadowOffsety
The Y offset of the shadow.
Default: 2

shadowBlur
The blurring of the shadow.
Default: 2

shadowOpacity
The opacity of the shadow colour.
Default: 0.25

 

Title

Properties: title, titleX, titleY, titleHalign, titleValign, titleColor, titleFont, titleSize, titleBold, titleItalic, titleSubtitle, titleSubtitleX, titleSubtitleY, titleSubtitleHalign, titleSubtitleValign, titleSubtitleColor, titleSubtitleFont, titleSubtitleSize, titleBold, titleSubtitleItalic

title
The title of the chart.
Default: (An empty string)

titleX
The specific X coordinate of the title.
Default: null

titleY
The specific Y coordinate of the title.
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: false

titleItalic
Whether the title is italic or not.
Default: false

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 gutterTop value.
Default: (An empty string)

titleSubtitleX
The specific X coordinate of the subtitle.
Default: null

titleSubtitleY
The specific Y coordinate of the subtitle.
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 the same as the textSize setting.
Default: null

titleBold
Whether the subtitle is bold or not.
Default: false

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

 

Tooltips

Properties: tooltips, tooltipsOverride, tooltipsCssClass, tooltipsEvent

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 thats applied to the tooltip DIV.
Default: RGraph_tooltip

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

 

Highlight

Properties: highlightStroke, highlightFill, highlightLinewidth

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

 

Scale

Properties: scaleVisible, scaleUnitsPre, scaleUnitsPost, scaleMin, scaleMax, scalePoint, scaleThousand, scaleRound, scaleDecimals, scaleFormatter, scaleBold, scaleItalic, scaleColor, scaleSize, scaleFont, scaleLabelsCount

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

scaleUnitsPre
The units which are PREPENDED to the numbers.
Default: (an empty string)

scaleUnitsPost
The units which are APPENDED to the numbers.
Default: (an empty string)

scaleMin
The minimum scale value.
Default: 0

scaleMax
The maximum scale value
Default: null

scalePoint
The character to use as the decimal point.
Default: .

scaleThousand
The character to use as the thousand seperator.
Default: ,

scaleRound
Whether to round the maximum scale value up.
Default: false

scaleDecimals
The number of decimal places to display.
Default: 0

scaleFormatter
A function that handles all of the formatting of the value. The function should look like this:
function (obj, num)
{
}

Default: null

scaleBold
Whether the scale values are bold or not. This falls back to the textBold setting if left as null.
Default: null

scaleItalic
Whether the scale values are italic or not. This falls back to the textItalic setting if left as null.
Default: null

scaleColor
The color of the scale labels. This falls back to the textColor setting if left as null.
Default: null

scaleSize
The size of the scale labels. This falls back to the textSize setting if left as null.
Default: null

scaleFont
The font of the scale labels. This falls back to the textFont setting if left as null.
Default: null

scaleLabelsCount
The number of scale labels.
Default: 5

 

Tickmarks

Properties: tickmarks, tickmarksLinewidth, tickmarksSize, tickmarksFill

tickmarks
The style of tickmarks that are used. You set this to false to disable tickmarks. This can be either a string or an array of tickmark styles:
Default: circle

tickmarksLinewidth
The linewidth used for the tickmarks.
Default: 1

tickmarksSize
The overall size of the tickmarks.
Default: 6

tickmarksFill
The fill color used for tickmarks (when in circle mode or rect mode.).
Default: white

 

Attribution

Properties: attribution, attributionX, attributionY, attributionHref, attributionHalign, attributionValign, attributionFont, attributionSize, attributionColor, attributionItalic, attributionBold

attribution
Whether to show the attribution link or not. If you're going to link to the RGraph website elsewhere on your site then set this to false.
Default: true

attributionX
The X coordinate of the link. This can be a number (in which case it's treated as the absolute coordinate) or it can be a string starting with a + or - (in which case it's treated as an adjustment to the default value).
Default: (bottom right corner of the SVG tag)

attributionY
The Y coordinate of the link. This can be a number (in which case it's treated as the absolute coordinate) or it can be a string starting with a + or - (in which case it's treated as an adjustment to the default value).
Default: (bottom right corner of the SVG tag)

attributionHref
The href of the link (ie the page to link to).
Default: http://www.rgraph.net/svg/index.html

attributionHalign
The horizontal alignment of the link.
Default: right

attributionValign
The vertical alignment of the link
Default: bottom

attributionFont
The font used to render the link.
Default: sans-serif

attributionSize
The point size of the link.
Default: 8

attributionColor
The color of the link.
Default: gray

attributionItalic
Whether the link is italic or not.
Default: false

attributionBold
Whether the link is bold or not.
Default: false

 

Other

Properties: linewidth

linewidth
The linewidth of the seperating lines.
Default: 1

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)

If you like RGraph please share it:

Comments