SVG Scatter charts API reference

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

 

Example

The code below produces a chart like this:

<script>
    var data = [
        {x:'1st January',y:0},      {x:'5th April',y:5.56},
        {x:'27th February',y:23},   {x:'4th April',y:46},
        {x:'1st October',y:18},     {x:'28th September',y:43},
        {x:'23rd August',y:50},     {x:'1st June',y:12},
        {x:'1st March',y:32},       {x:'27th July',y:12},
        {x:'23rd April',y:32},      {x:'1st January',y:50},
        {x:'3rd November',y:23},    {x:'12th December',y:15},
        {x:'4th May',y:41}
    ];

    new RGraph.SVG.Scatter({
        id: 'chart-container',
        data: data,
        options: {
            marginLeft: 100,
            yaxisScaleDecimals: 2,
            xaxisScaleMin: '1st January 00:00:00',
            xaxisScaleMax: '31st December 23:59:59',
            xaxisLabels: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
            tickmarksStyle: 'cross'
        }
    }).draw();
</script>

 

How to specify the Scatter chart data

The Scatter chart is slightly different to other charts because, whereas other charts (usually) use arrays of information to specify values, the Scatter chart uses an array of objects. This should come quite naturally though as each Scatter chart point can have several different attributes (eg X value, Y value, tooltip etc). At its most basic it looks like this:

    var data = [
        {x:5,y:7}, {x:7,y:9}, {x:1,y:3}
    ];

That would define three points, each with X and Y values. There are other things that you can add to each object (or just one/two etc) and they are:

Another example where each point has all of the options specified is:

    var data = [
        {x:5,y:7,type: 'triangle',color: 'green', size: 10,opacity: 0.75,tooltip: 'The first tickmark'},
        {x:7,y:9,type: 'square',color: 'red', size: 15,opacity: 0.5,tooltip: 'The second tickmark'},
        {x:1,y:3,type: 'cross',color: 'cyan', size: 15,opacity: 0.25,tooltip: 'The third tickmark'}
    ];

 

Using dates and times instead of numeric X values

Instead of numeric X values, you can instead give a datetime string that RGraph will parse (using the RGraph.SVG.parseDate() function) and use as the value instead. The xaxisScaleMin and xaxisScaleMax values can also be specified like this too. The format of the datetime string can be varied (as you can see from the example below). Here's an example of a datetime chart.

<script>
    data = [
        {x:'23:59 15-01-2012', y:5},
        {x:'2012 15th February', y:6},
        {x:'Mar 15 2012', y:6},
        {x:'2012/04/15', y:6},
        {x:'2012-05.15', y:5},
        {x:'2012 June 15', y:4},
        {x:'July 2012 15th', y:5},
        {x:'Aug 15th 2012', y:6},
        {x:'15th September 2012', y:7},
        {x:'15 Oct 2012', y:6},
        {x:'2012.11.15', y:4},
        {x:'2012.12-15 00:00:00', y:5}
    ];
    
    new RGraph.SVG.Scatter({
        id: 'chart-container',
        data: data,
        options: {
            backgroundGridVlines: false,
            backgroundGridBorder: false,
            yaxis: false,
            colors: ['red'],
            title: 'A Scatter chart using datetime values',
            xaxisScaleMin: '2012/01/06 12:14:12',
            xaxisScaleMax: '31st dec 2012'
        }
    }).draw();
</script>

 

Using image based tickmarks

If the list of tickmarks does not suit your needs you can use an image as your tickmark instead. You can specify one by doing this:

<script>
    new RGraph.SVG.Scatter({
        id: 'image-based-tickmarks',
        data: [
            {x: 50, y: 26, type:'image:/images/logo.png'},
            {x: 100, y: 26, type:'image:/images/coins.png'},
            {x: 150, y: 26, type:'image:/images/atom.png'},
            {x: 200, y: 26, type:'image:/images/alert.png'},
            {x: 250, y: 26, type:'image:/images/alex.png'}
        ],
        options: {
            title: 'A Scatter chart using image based tickmarks',
            xaxisScaleMin: 0,
            xaxisScaleMax: 365,
            xaxisLabels: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
        }
    }).draw();
</script>

 

Adding a line connecting the tickmarks

By using the line option you can have a line connecting the points therefore creating a line chart - but with this line chart (instead of the regular line chart ) the points are not necessarily a fixed width apart - the X value is totally down to you along with the Y value. The datetime chart above is also showing an example of using the line option.

With a little configuration you can use the Scatter chart with this line option to show a vertical line chart instead of a horizontal one. There's an example that shows you an example of it in the download archive.

 

Showing the coordinates using the labelsAbove feature

The Scatter chart has the labelsAbove feature - just like the Bar, Line and Waterfall charts. It's enabled a little differently though. Instead of setting the labelsAbove property to true you set the above property in each points configuration object in the data to true. Like this:

<script>
    var data = [
        {x:0,   y:0,  above:true},
        {x:100, y:5,  above:true},
        {x:84,  y:23, above:true},
        {x:65,  y:46, above:true},
        {x:221, y:18, above:true}
    ];

    new RGraph.SVG.Scatter({
        id: 'chart-container',
        data: data,
        options: {
            xaxisScaleMax: 365,
            xaxisLabels: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
        }
    }).draw();
</script>

You can then use the labelsAbove configuration properties that are shown below to configure their appearance as normal.

 

The coordinates properties

The coordinates of all of the marks that are on the Scatter chart are held in the obj.coords and obj.coords2 arrays. The difference in the two is how they're indexed - the obj.coords array is simply a sequential array where each points information is simply appended to the array. The obj.coords2 array on the other hand is indexed by dataset and then by the index in that dataset. So if you have two datasets each having six points then the obj.coords array would look like this:

And the obj.coords2 array would look like this: Each datapoint is an object that consists of the following:

 

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

Background properties

PropertyDescriptionDefault
backgroundColorThe color of the background.null
backgroundImageA URL of an image to render to the background.null
backgroundImageAspectThe aspect ration setting of the SVG image tag, eg it could be XMinYMin meet.none
backgroundImageOpacityThe alpha/opacity value of the background image.0.5
backgroundImageStretchWhether the background image is stretched across the whole chart (except the margins).true
backgroundImageXIf you're not using the stretch option you can specify the X coordinate of the image.null
backgroundImageXIf you're not using the stretch option you can specify the Y coordinate of the image.null
backgroundImageWIf you're not using the stretch option you can specify the width of the image.null
backgroundImageHIf you're not using the stretch option you can specify the height of the image.null
backgroundGridWhether to show the background grid or not.true
backgroundGridColorThe color of the background grid.#ddd
backgroundGridLinewidthThe linewidth that the background grid lines are. Decimals (eg 0.5) are permitted.1
backgroundGridBorderDetermines whether a border line is drawn around the grid.true
backgroundGridHlinesDetermines whether to draw the horizontal grid lines.true
backgroundGridHlinesCountDetermines how many horizontal grid lines you have. The default is linked to how many scale labels that you have.null
backgroundGridVlinesDetermines whether to draw the vertical grid lines.true
backgroundGridVlinesCountDetermines how many vertical grid lines you have. The default is to be linked to how many scale labels that you have.null
backgroundGridDashedYou can specify a dashed background grid by setting this to true. This option takes precedence over the dotted variant.false
backgroundGridDottedYou can specify a dotted background grid by setting this to true.false
backgroundGridDashArrayWith this option you can specify exactly what the array used for the linedash setting should be. It should be an array consisting of two numbers.null
backgroundColor
The color of the background.
Default: null

backgroundImage
A URL of an image to render to the background.
Default: null

backgroundImageAspect
The aspect ration setting of the SVG image tag, eg it could be XMinYMin meet.
Default: none

backgroundImageOpacity
The alpha/opacity value of the background image.
Default: 0.5

backgroundImageStretch
Whether the background image is stretched across the whole chart (except the margins).
Default: true

backgroundImageX
If you're not using the stretch option you can specify the X coordinate of the image.
Default: null

backgroundImageX
If you're not using the stretch option you can specify the Y coordinate of the image.
Default: null

backgroundImageW
If you're not using the stretch option you can specify the width of the image.
Default: null

backgroundImageH
If you're not using the stretch option you can specify the height of the image.
Default: null

backgroundGrid
Whether to show the background grid or not.
Default: true

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

backgroundGridLinewidth
The linewidth that the background grid lines are. Decimals (eg 0.5) are permitted.
Default: 1

backgroundGridBorder
Determines whether a border line is drawn around the grid.
Default: true

backgroundGridHlines
Determines whether to draw the horizontal grid lines.
Default: true

backgroundGridHlinesCount
Determines how many horizontal grid lines you have. The default is linked to how many scale labels that you have.
Default: null

backgroundGridVlines
Determines whether to draw the vertical grid lines.
Default: true

backgroundGridVlinesCount
Determines how many vertical grid lines you have. The default is to be linked to how many scale labels that you have.
Default: null

backgroundGridDashed
You can specify a dashed background grid by setting this to true. This option takes precedence over the dotted variant.
Default: false

backgroundGridDotted
You can specify a dotted background grid by setting this to true.
Default: false

backgroundGridDashArray
With this option you can specify exactly what the array used for the linedash setting should be. It should be an array consisting of two numbers.
Default: null

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

Tickmark properties

PropertyDescriptionDefault
tickmarksStyleThe style of the tickmarks. This can be a string, or it can also be an array of different types which are used on a per-dataset basis. You can also specify the type: attribute in the data set (see above). Possible types are:
  • cross
  • image:xxx
  • triangle
  • plus
  • square (or rect)
  • circle (or dot)
cross
tickmarksSizeThe size of the tickmarks. It can be a number or an array of numbers, one for each dataset. This can be overridden on a per-point basis by using the size property in each points configuration data.7
tickmarksStyle
The style of the tickmarks. This can be a string, or it can also be an array of different types which are used on a per-dataset basis. You can also specify the type: attribute in the data set (see above). Possible types are:
Default: cross

tickmarksSize
The size of the tickmarks. It can be a number or an array of numbers, one for each dataset. This can be overridden on a per-point basis by using the size property in each points configuration data.
Default: 7

X axis properties

PropertyDescriptionDefault
xaxisWhether the X axis is shown or not.true
xaxisLinewidthThe linewidth that's used to draw the X axis.1
xaxisTickmarksWhether the X axis has tickmarks or not.true
xaxisTickmarksLengthThe size of the X axis tickmarks.5
xaxisColorThe color of the X axis.black
xaxisLabelsAn array of labels that are spread across the X axis.null
xaxisLabelsColorThe color of the X axis text.null
xaxisLabelsBoldWhether the X axis text is bold or not.null
xaxisLabelsItalicWhether the X axis text is italic or not.null
xaxisLabelsFontThe font of the X axis text.null
xaxisLabelsSizeThe size of the X axis text.null
xaxisLabelsOffsetxThe X pixel offset that's added to the X axis labels.0
xaxisLabelsOffsetyThe Y pixel offset that's added to the X axis labels.0
xaxisLabelsPositionSectionTickmarksCountNot something you'll use often, if at all. Determines how many tickmarks there are.null
xaxisLabelsPositionEdgeTickmarksCountIf you're showing a scale then you'll probably want to control the number of tickmarks that are displayed. You can do that with this property.10
xaxisLabelsCountThe number of labels that are shown on the X axis scale.10
xaxisLabelsAngleIf you have long labels you may want to set this to a number between 0 and 90 to enable angled labels.null
xaxisScaleIf set to true then a scale will be shown instead of labels. The scale is based around the xaxisScaleMax value that you set.null
xaxisScaleDecimalsThe number of decimal places that are used for values on the X scale.0
xaxisScaleUnitsPreUnits that are prepended to the number on the X axis scale.[an empty string]
xaxisScaleUnitsPostUnits that are appended to the number on the X axis scale.[an empty string]
xaxisScalePointThe character that's used for the decimal point on the X axis scale..
xaxisScaleThousandThe character that's used for the thousand separator on the X axis scale.,
xaxisScaleFormatterUsed by the X axis scale - this should be a function that's passed two arguments - the object and the number - and should return the number formatted the way you wish.
xaxisFormatter: function (obj, num)
{
    return num;
}
xaxis
Whether the X axis is shown or not.
Default: true

xaxisLinewidth
The linewidth that's used to draw the X axis.
Default: 1

xaxisTickmarks
Whether the X axis has tickmarks or not.
Default: true

xaxisTickmarksLength
The size of the X axis tickmarks.
Default: 5

xaxisColor
The color of the X axis.
Default: black

xaxisLabels
An array of labels that are spread across the X axis.
Default: null

xaxisLabelsColor
The color of the X axis text.
Default: null

xaxisLabelsBold
Whether the X axis text is bold or not.
Default: null

xaxisLabelsItalic
Whether the X axis text is italic or not.
Default: null

xaxisLabelsFont
The font of the X axis text.
Default: null

xaxisLabelsSize
The size of the X axis text.
Default: null

xaxisLabelsOffsetx
The X pixel offset that's added to the X axis labels.
Default: 0

xaxisLabelsOffsety
The Y pixel offset that's added to the X axis labels.
Default: 0

xaxisLabelsPositionSectionTickmarksCount
Not something you'll use often, if at all. Determines how many tickmarks there are.
Default: null

xaxisLabelsPositionEdgeTickmarksCount
If you're showing a scale then you'll probably want to control the number of tickmarks that are displayed. You can do that with this property.
Default: 10

xaxisLabelsCount
The number of labels that are shown on the X axis scale.
Default: 10

xaxisLabelsAngle
If you have long labels you may want to set this to a number between 0 and 90 to enable angled labels.
Default: null

xaxisScale
If set to true then a scale will be shown instead of labels. The scale is based around the xaxisScaleMax value that you set.
Default: null

xaxisScaleDecimals
The number of decimal places that are used for values on the X scale.
Default: 0

xaxisScaleUnitsPre
Units that are prepended to the number on the X axis scale.
Default: [an empty string]

xaxisScaleUnitsPost
Units that are appended to the number on the X axis scale.
Default: [an empty string]

xaxisScalePoint
The character that's used for the decimal point on the X axis scale.
Default: .

xaxisScaleThousand
The character that's used for the thousand separator on the X axis scale.
Default: ,

xaxisScaleFormatter
Used by the X axis scale - this should be a function that's passed two arguments - the object and the number - and should return the number formatted the way you wish.
xaxisFormatter: function (obj, num)
{
    return num;
}

Default:

Y axis properties

PropertyDescriptionDefault
yaxisWhether the Y axis is shown or not.true
yaxisColorThe color of the Y axis.black
yaxisLinewidthThe linewidth that's used to draw the Y axis.1
yaxisTickmarksWhether the Y axis has tickmarks or not.true
yaxisTickmarksLengthThe size of the Y axis tickmarks.5
yaxisLabelsIf the yaxisScale option is false then this can be used to give an array of labels that are shown on the Y axis instead.null
yaxisLabelsOffsetxThe X pixel offset that's added to the Y axis labels.0
yaxisLabelsOffsetyThe Y pixel offset that's added to the Y axis labels.0
yaxisLabelsHalignThe horizontal alignment of the labels.right
yaxisLabelsValignThe vertical alignment of the labels.center
yaxisLabelsCountThe number of Y labels.5
yaxisLabelsPositionEdgeTickmarksCountNot something you'll use often, if at all. Determines how many tickmarks there are.null
yaxisLabelsColorThe color of the Y axis text.null
yaxisLabelsBoldWhether the Y axis text is bold or not.null
yaxisLabelsItalicWhether the Y axis text is italic or not.null
yaxisLabelsFontThe font of the Y axis text.null
yaxisLabelsSizeThe size of the Y axis text.null
yaxisScaleWhether the Y axis scale is shown.true
yaxisScaleUnitsPreUnits that are prepended to the scale numbers. (An empty string
yaxisScaleUnitsPostUnits that are appended to the scale numbers.(An empty string
yaxisScaleDecimalsThe number of decimals that the scale will show.0
yaxisScalePointThe character(s) used as the decimal point..
yaxisScaleThousandThe character(s) used as the thousand separator.,
yaxisScaleRoundIf set to true the max scale value will be rounded up.false
yaxisScaleMaxThe maximum Y scale value.null
yaxisScaleMinThe minimum Y scale value. As well as a numeric value you can also set this to mirror so that the X axis is put in the center.0
yaxisScaleFormatterThis option should be a function. This function handles the entirety of the number formatting for the Y axis. Units are not added, decimals are not added - it's all up to you. The function is passed two arguments - the chart object and the number. It should look like this:
yaxisFormatter: function (obj, num)
{
}
null
yaxis
Whether the Y axis is shown or not.
Default: true

yaxisColor
The color of the Y axis.
Default: black

yaxisLinewidth
The linewidth that's used to draw the Y axis.
Default: 1

yaxisTickmarks
Whether the Y axis has tickmarks or not.
Default: true

yaxisTickmarksLength
The size of the Y axis tickmarks.
Default: 5

yaxisLabels
If the yaxisScale option is false then this can be used to give an array of labels that are shown on the Y axis instead.
Default: null

yaxisLabelsOffsetx
The X pixel offset that's added to the Y axis labels.
Default: 0

yaxisLabelsOffsety
The Y pixel offset that's added to the Y axis labels.
Default: 0

yaxisLabelsHalign
The horizontal alignment of the labels.
Default: right

yaxisLabelsValign
The vertical alignment of the labels.
Default: center

yaxisLabelsCount
The number of Y labels.
Default: 5

yaxisLabelsPositionEdgeTickmarksCount
Not something you'll use often, if at all. Determines how many tickmarks there are.
Default: null

yaxisLabelsColor
The color of the Y axis text.
Default: null

yaxisLabelsBold
Whether the Y axis text is bold or not.
Default: null

yaxisLabelsItalic
Whether the Y axis text is italic or not.
Default: null

yaxisLabelsFont
The font of the Y axis text.
Default: null

yaxisLabelsSize
The size of the Y axis text.
Default: null

yaxisScale
Whether the Y axis scale is shown.
Default: true

yaxisScaleUnitsPre
Units that are prepended to the scale numbers.
Default: (An empty string

yaxisScaleUnitsPost
Units that are appended to the scale numbers.
Default: (An empty string

yaxisScaleDecimals
The number of decimals that the scale will show.
Default: 0

yaxisScalePoint
The character(s) used as the decimal point.
Default: .

yaxisScaleThousand
The character(s) used as the thousand separator.
Default: ,

yaxisScaleRound
If set to true the max scale value will be rounded up.
Default: false

yaxisScaleMax
The maximum Y scale value.
Default: null

yaxisScaleMin
The minimum Y scale value. As well as a numeric value you can also set this to mirror so that the X axis is put in the center.
Default: 0

yaxisScaleFormatter
This option should be a function. This function handles the entirety of the number formatting for the Y axis. Units are not added, decimals are not added - it's all up to you. The function is passed two arguments - the chart object and the number. It should look like this:
yaxisFormatter: function (obj, num)
{
}

Default: null

Other text properties

PropertyDescriptionDefault
textColorThe color of the text.black
textFontThe font used for text.Arial, Verdana, sans-serif
textSizeThe size of the text.12
textBoldWhether the text is bold or not.false
textItalicWhether the text is italic or not.false
labelsAboveWith the Scatter chart labelsAbove isn't enabled by using this property - it's enabled by using the "above" parameter within each points configuration object in the data (the place where you specify the X and Y values).N/A - see above
labelsAboveXPointThe decimal point character to use for the labelsAbove labels (this is for the X coordinate).null
labelsAboveXThousandThe thousand separator character to use for the labelsAbove labels (this is for the X coordinate).null
labelsAboveXDecimalsThe number of decimals to use for the labelsAbove labels (this is for the X coordinate).0
labelsAboveXDecimalsTrimIf there are trailing zeros on the number (only decimals though) by enabling this they will be stripped. This is for the X coordinate.false
labelsAboveXUnitsPreA string to prepend to the labelsAbove labels (this is for the X coordinate).null
labelsAboveXUnitsPostA string to append to the labelsAbove labels (this is for the X coordinate).null
labelsAboveXFormatterA function that handles ALL of the formatting of the number. The function is passed two arguments - the object and the unformatted number. This is for the X coordinate.null
labelsAboveYPointThe decimal point character to use for the labelsAbove labels (this is for the Y coordinate).null
labelsAboveYThousandThe thousand separator character to use for the labelsAbove labels (this is for the Y coordinate).null
labelsAboveYDecimalsThe number of decimals to use for the labelsAbove labels (this is for the Y coordinate).0
labelsAboveYDecimalsTrimIf there are trailing zeros on the number (only decimals though) by enabling this they will be stripped. This is for the Y coordinate.false
labelsAboveYUnitsPreA string to Prepend to the labelsAbove labels (this is for the Y coordinate).null
labelsAboveYUnitsPostA string to append to the labelsAbove labels (this is for the Y coordinate).null
labelsAboveYFormatterA function that handles ALL of the formatting of the number. The function is passed two arguments - the object and the unformatted number. This is for the Y coordinate.null
labelsAboveOffsetxThe horizontal offset of the labelsAbove labels.0
labelsAboveOffsetyThe vertical offset of the labelsAbove labels.-10
labelsAboveFontThe font of the labelsAbove labels.null
labelsAboveSizeThe size of the labelsAbove labels.null
labelsAboveBoldWhether the labelsAbove labels are bold or not.null
labelsAboveItalicWhether the labelsAbove labels are italic or not.null
labelsAboveColorThe color of the labelsAbove labels.null
labelsAboveBackgroundThe background color of the labelsAbove labels.rgba(255,255,255,0.7)
labelsAboveBackgroundPaddingThe padding of the labelsAbove labels.2
labelsAboveHalignThe horizontal alignment of the labelsAbove.center
labelsAboveValignThe vertical alignment of the labelsAbove.bottom
labelsAboveSpecificThis property is not used by the Scatter chart. If you wish to specify a literal string then you can do so by setting the above: property in the points object (in the data array) to that string (instead of it simply being true).null
labelsAboveSeparatorThis property allows you to set the comma in the labelsAbove to any character you want. It can be multiple characters if you want.,
textColor
The color of the text.
Default: black

textFont
The font used for text.
Default: Arial, Verdana, sans-serif

textSize
The size of the text.
Default: 12

textBold
Whether the text is bold or not.
Default: false

textItalic
Whether the text is italic or not.
Default: false

labelsAbove
With the Scatter chart labelsAbove isn't enabled by using this property - it's enabled by using the "above" parameter within each points configuration object in the data (the place where you specify the X and Y values).
Default: N/A - see above

labelsAboveXPoint
The decimal point character to use for the labelsAbove labels (this is for the X coordinate).
Default: null

labelsAboveXThousand
The thousand separator character to use for the labelsAbove labels (this is for the X coordinate).
Default: null

labelsAboveXDecimals
The number of decimals to use for the labelsAbove labels (this is for the X coordinate).
Default: 0

labelsAboveXDecimalsTrim
If there are trailing zeros on the number (only decimals though) by enabling this they will be stripped. This is for the X coordinate.
Default: false

labelsAboveXUnitsPre
A string to prepend to the labelsAbove labels (this is for the X coordinate).
Default: null

labelsAboveXUnitsPost
A string to append to the labelsAbove labels (this is for the X coordinate).
Default: null

labelsAboveXFormatter
A function that handles ALL of the formatting of the number. The function is passed two arguments - the object and the unformatted number. This is for the X coordinate.
Default: null

labelsAboveYPoint
The decimal point character to use for the labelsAbove labels (this is for the Y coordinate).
Default: null

labelsAboveYThousand
The thousand separator character to use for the labelsAbove labels (this is for the Y coordinate).
Default: null

labelsAboveYDecimals
The number of decimals to use for the labelsAbove labels (this is for the Y coordinate).
Default: 0

labelsAboveYDecimalsTrim
If there are trailing zeros on the number (only decimals though) by enabling this they will be stripped. This is for the Y coordinate.
Default: false

labelsAboveYUnitsPre
A string to Prepend to the labelsAbove labels (this is for the Y coordinate).
Default: null

labelsAboveYUnitsPost
A string to append to the labelsAbove labels (this is for the Y coordinate).
Default: null

labelsAboveYFormatter
A function that handles ALL of the formatting of the number. The function is passed two arguments - the object and the unformatted number. This is for the Y coordinate.
Default: null

labelsAboveOffsetx
The horizontal offset of the labelsAbove labels.
Default: 0

labelsAboveOffsety
The vertical offset of the labelsAbove labels.
Default: -10

labelsAboveFont
The font of the labelsAbove labels.
Default: null

labelsAboveSize
The size of the labelsAbove labels.
Default: null

labelsAboveBold
Whether the labelsAbove labels are bold or not.
Default: null

labelsAboveItalic
Whether the labelsAbove labels are italic or not.
Default: null

labelsAboveColor
The color of the labelsAbove labels.
Default: null

labelsAboveBackground
The background color of the labelsAbove labels.
Default: rgba(255,255,255,0.7)

labelsAboveBackgroundPadding
The padding of the labelsAbove labels.
Default: 2

labelsAboveHalign
The horizontal alignment of the labelsAbove.
Default: center

labelsAboveValign
The vertical alignment of the labelsAbove.
Default: bottom

labelsAboveSpecific
This property is not used by the Scatter chart. If you wish to specify a literal string then you can do so by setting the above: property in the points object (in the data array) to that string (instead of it simply being true).
Default: null

labelsAboveSeparator
This property allows you to set the comma in the labelsAbove to any character you want. It can be multiple characters if you want.
Default: ,

Line properties

PropertyDescriptionDefault
lineThis can either be a boolean or an array of booleans that determines whether a line is drawn connecting the points (for each dataset).false
lineColorsThis can either be a string or an array of strings that determines the colors of the lines that are drawn.black
lineLinewidthThis can either be a number or an array of numbers that determines the colors of the lines that are drawn.black
line
This can either be a boolean or an array of booleans that determines whether a line is drawn connecting the points (for each dataset).
Default: false

lineColors
This can either be a string or an array of strings that determines the colors of the lines that are drawn.
Default: black

lineLinewidth
This can either be a number or an array of numbers that determines the colors of the lines that are drawn.
Default: black

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. If not specified it defaults to the textFont setting.null
keyLabelsSizeThe size to use for the key text. If not specified then the textSize is used.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. If not specified it defaults to the textFont setting.
Default: null

keyLabelsSize
The size to use for the key text. If not specified then the textSize is used.
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
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
highlightFillThe fill color that's used when highlighting the chart.rgba(255,255,255,0.7)
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

highlightFill
The fill color that's used when highlighting the chart.
Default: rgba(255,255,255,0.7)

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.null
titleFontThe font used to render the title.null
titleSizeThe size of the font used to render the title.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.
Default: null

titleFont
The font used to render the title.
Default: null

titleSize
The size of the font used to render the title.
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

Bubble chart properties

PropertyDescriptionDefault
bubbleWhether your Scatter chart should be drawn as a Bubble chart. As well as X and Y coordinates Bubble charts also require a Z coordinate. You can see an example of a Bubble chart in the download archive.false
bubbleMaxValueThe maximum value that the bubbles have (the maximum Z value).null
bubbleMaxRadiusThe maximum radius that bubbles can have. So Z values that equal the maximum Z value (as defined with the above property) will be this wide.null
bubbleColorsSolidBy default the bubbles are drawn using a gradient so that they have a 3D appearance. You can turn this off and have flat bubbles with this option.false
bubble
Whether your Scatter chart should be drawn as a Bubble chart. As well as X and Y coordinates Bubble charts also require a Z coordinate. You can see an example of a Bubble chart in the download archive.
Default: false

bubbleMaxValue
The maximum value that the bubbles have (the maximum Z value).
Default: null

bubbleMaxRadius
The maximum radius that bubbles can have. So Z values that equal the maximum Z value (as defined with the above property) will be this wide.
Default: null

bubbleColorsSolid
By default the bubbles are drawn using a gradient so that they have a 3D appearance. You can turn this off and have flat bubbles with this option.
Default: false

Error bar properties

PropertyDescriptionDefault
errorbarsThis is just a placeholder - with Scatter charts the errorbar information is supplied in each points object within the data array.No errorbars are shown by default
errorbarsColorThe default color of the errorbars. This can be overridden using the color setting if you give an object as the errorbar property in the data array.black
errorbarsLinewidthThe linewidth that is used to draw the errorbars. This can be overridden using the linewidth setting if you give an object as the errorbar property in the data array.1
errorbarsCapwidthThe width of the caps to the errorbars. This can be overridden using the capwidth setting if you give an object as the errorbar property in the data array.10
errorbars
This is just a placeholder - with Scatter charts the errorbar information is supplied in each points object within the data array.
Default: No errorbars are shown by default

errorbarsColor
The default color of the errorbars. This can be overridden using the color setting if you give an object as the errorbar property in the data array.
Default: black

errorbarsLinewidth
The linewidth that is used to draw the errorbars. This can be overridden using the linewidth setting if you give an object as the errorbar property in the data array.
Default: 1

errorbarsCapwidth
The width of the caps to the errorbars. This can be overridden using the capwidth setting if you give an object as the errorbar property in the data array.
Default: 10

 

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.getYCoord(value)

This method can be used to get an appropriate X coordinate for a value when you're doing custom drawing on the chart. It returns null if the value is out of range.

 

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)