About
RGraph is a JavaScript charts library based on HTML5 SVG and canvas. RGraph is mature (over 15 years old) and has a wealth of features making it an ideal choice to show charts on your website.

More »

 

License
RGraph can be used for free under the GPL or if that doesn't suit your situation there's an inexpensive (£99) commercial license available.

More »

 

Download
Get the latest version of RGraph (version 6.17) from the download page. There's also older versions available, minified files and links to cdnjs.com hosted libraries.

More »

Scatter chart API reference

Example

An example Scatter chart
<script>
    tooltip = '%{key}';

    new RGraph.Scatter({
        id: 'cvs',
        data: [
            [
                [10,78,null,tooltip],
                [20,69,null,tooltip],
                [34,42,null,tooltip],
                [35,66,null,tooltip],
                [46,45,null,tooltip],
                [64,38,null,tooltip],
                [78,29,null,tooltip],
                [78,34,null,tooltip],
                [112,26,null,tooltip],
                [119,15,null,tooltip]
            ],
            [
                [186,54,'red',tooltip],
                [195,56,'red',tooltip],
                [210,58,'red',tooltip],
                [214,53,'blue',tooltip],
                [233,51,'red',tooltip],
                [245,48,'red',tooltip],
                [270,61,'red',tooltip],
                [281,43,'red',tooltip],
                [299,52,'red',tooltip],
                [312,77,'red',tooltip]
            ]
        ],
        options: {
            tooltipsFormattedKeyLabels: ['Richard','John','Luis','Pob','Pete','Olga','Kiffen','Hevin','Joy','Hoolio'],
            tooltipsFormattedKeyColors: ['black','red'],
            tooltipsCss: {
                fontSize: '16pt',
                boxShadow: '',
                textAlign: 'left'
            },
            trendline: true,
            trendlineColor: ['gray','red'],
            trendlineMargin: 5,
            backgroundGridBorder: false,
            backgroundGridVlines: false,
            yaxis: false,
            backgroundGridColor: '#eee',
            marginLeft: 30,
            xaxisLabels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
            xaxisScaleMax: 365,
            tickmarksSize: 10
        }
    }).draw();
</script>

Format of the data array (colors/tooltips)

Each point on the Scatter chart is made by supplying an array of up to 4 elements (from version 6.11 it can also be an object which has up to four properties - details below):

If you wish to specify a tooltip, but not a color (ie use the default color instead), you can pass null instead of a color.

<script>
    //
    // A single dataset
    //
    data = [
        [67,78],                            // A basic datapoint
        [67,40,'red'],                      // A datapoint with a color specified
        [150,26,'green','A tooltip!'],      // A datapoint with a color and tooltip specified
        [164,35, null, 'Just the tooltip'], // A datapoint with no color and a tooltip
    ];
    
    //
    // Multiple datasets
    //
    data = [
        [
            [67,78],                           // A basic datapoint
            [67,40,'red'],                     // A datapoint with a color specified
            [150,26,'green','A tooltip!'],     // A datapoint with a color and tooltip specified
            [164,35, null, 'Just the tooltip'] // A datapoint with no color and a tooltip
        ],
        [
            [7,41],
            [9,45,'red'],
            [8,23,'green','A tooltip!'],
            [15,32, null, 'Just the tooltip']
        ]
    ];
    
    

    new RGraph.Scatter({
        id: 'cvs',
        data: data,
        options: {
            xaxisScaleMax: 365
        }
    }).draw();
</script>

Object based point definitions

From version 6.11 the canvas Scatter chart can handle the array for each point being an object instead. You may find that this is easier to create and understand. There's an example of this below that shows the datasets from the above code converted to use objects instead.

<script>
    //
    // A single dataset
    //
    data = [
        {x: 67,  y: 78 },                                       // A basic datapoint
        {x: 67,  y: 40, color: 'red'},                          // A datapoint with a color specified
        {x: 150, y: 26, color: 'green', tooltip: 'A tooltip!'}, // A datapoint with a color and tooltip specified
        {x: 164, y: 35, tooltip: 'Just the tooltip'}            // A datapoint with no color and a tooltip
    ];
    
    //
    // Multiple datasets
    //
    data = [
        [
            {x: 67,  y: 78},                                        // A basic datapoint
            {x: 67,  y: 40, color: 'red'},                          // A datapoint with a color specified
            {x: 150, y: 26, color: 'green', tooltip: 'A tooltip!'}, // A datapoint with a color and tooltip specified
            {x: 164, y: 35, tooltip: 'Just the tooltip'}            // A datapoint with no color and a tooltip
        ],
        [
            {x: 7,  y: 41},
            {x: 9,  y: 45, color: 'red'},
            {x: 8,  y: 23, color: 'green', tooltip: 'A tooltip!'},
            {x: 15, y: 32, tooltip: 'Just the tooltip'}
        ]
    ];
    
    

    new RGraph.Scatter({
        id: 'cvs',
        data: data,
        options: {
            xaxisScaleMax: 365
        }
    }).draw();
</script>

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

Name: backgroundColor
Description: 
If you want to have a single background color for your chart you can use this. It doesn't cover the margins. If you want that then you can simply apply a css background color to the canvas tag.
Default: null
Name: backgroundBarsCount
Description: 
The number of background bars.
Default: 5
Name: backgroundBarsColor1
Description: 
The color of the background bars. (1 of 2).
Default: rgba(0,0,0,0)
Name: backgroundBarsColor2
Description: 
The color of the background bars. (2 of 2).
Default: rgba(0,0,0,0)
Name: backgroundGrid
Description: 
Whether to show the background grid or not.
Default: true
Name: backgroundGridColor
Description: 
The color of the background grid.
Default: #eee
Name: backgroundHbars
Description: 
An array of information stipulating horizontal colored bars. You can use these to indicate limits. Eg:
myScatter.set('backgroundHbars', [[75, 10, 'yellow'], [85, 15, 'red']]);
This would give you two bars, one red and a lower yellow bar. The units correspond to your scale and are the starting point and the height.
Default: null
Name: backgroundVbars
Description: 
An array of vertical bar information. They're specified like his:
myScatter.set('backgroundVbars', [[0, 181, 'rgba(0,255,0,0.5)']]);
Normally the values are:
  • The start value
  • The extent of the bar (the width in scale terms)
  • The color
However when you're using a Date/Time chart that isn't very practical - so when you're using Date/Time values the two values that you specify should be the start and end Date/Times like this:
obj.set('backgroundVbars', [['2013/06/01','2013/07/01','pink']]);
Default: null
Name: backgroundGridBorder
Description: 
Determines whether a border is drawn around the grid.
Default: true
Name: backgroundGridHlines
Description: 
Determines whether to draw the horizontal gridlines.
Default: true
Name: backgroundGridVlines
Description: 
Determines whether to draw the vertical gridlines.
Default: true
Name: backgroundGridHlinesCount
Description: 
When using autofit this allows you to specify how many horizontal gridlines you want.
Default: 5
Name: backgroundGridVlinesCount
Description: 
When using autofit this allows you to specify how many vertical gridlines you want.
Default: 20
Name: backgroundGridAlign
Description: 
If you want to have your gridlines line up with the labels (both X and Y axes), you can set this to true and RGraph will attempt to make the gridlines line up.
Default: false
Name: backgroundGridDotted
Description: 
If you want to have your background grid dashed then set this to true.
Default: false
Name: backgroundGridDashed
Description: 
If you want to have your background grid dotted then set this to true. This takes precedence over dashed lines.
Default: false
Name: backgroundGridDashArray
Description: 
If you want a custom format for the line dash then you can give an array to this property. It should be an array of two or more numbers that specifies the size of dashes and gaps like this: [5, 10]
Default: null
Name: backgroundImage
Description: 
If you want to specify a background image to use on your chart, specify it with this property. If you use effects with a background image on your chart it may make the effect flicker. Using a background image with the draw event may mean that the event fires twice. There is a property that you can check though that is set when the image has loaded: obj.__rgraph_background_image_loaded__ Simply check this flag in your draw event. If it's true then the background image has loaded.
Default: null
Name: backgroundImageStretch
Description: 
By default your background image is stretched (if necessary) to cover the whole chart area (margins not included). If this is not what you want then set this property to false.
Default: true
Name: backgroundImageX
Description: 
The X coordinate of the image. The coordinates are the top left corner of the image.
Default: null
Name: backgroundImageY
Description: 
The Y coordinate of the image. The coordinates are the top left corner of the image.
Default: null
Name: backgroundImageW
Description: 
The width of the image. If you have a large canvas with many charts - you may need to specify this.
Default: null
Name: backgroundImageH
Description: 
The height of the image. If you have a large canvas with many charts - you may need to specify this.
Default: null
Name: backgroundImageAlign
Description: 
Instead of specifying the coordinates of the image, you can instead simply align it top, bottom, left or right. Examples are:
  • top left
  • bottom right
  • bottom
  • right
Default: null
Name: backgroundImageAlpha
Description: 
The alpha value (the opacity) of the image.
Default: 1
Name: backgroundBorder
Description: 
You can use this property to specify that the chart area has a border around it.
Default: false
Name: backgroundBorderLinewidth
Description: 
The linewidth of the border that goes around the chart area.
Default: 1
Name: backgroundBorderColor
Description: 
The color of the border that goes around the chart area.
Default: #aaa
Name: backgroundBorderDashed
Description: 
Whether the border around the chart area is dashed or not.
Default: false
Name: backgroundBorderDotted
Description: 
Whether the border around the chart area is dotted or not.
Default: false
Name: backgroundBorderDashArray
Description: 
If the default dot or dash style is not to your liking you can use this property to specify your own style. It should be an array of two or more elements that specify the dashes and spaces - for example: backgroundBorderDashArray: [5,10],
Default: null

X-axis properties

Name: xaxis
Description: 
Set this to true if you don't want an x-axis.
Default: true
Name: xaxisPosition
Description: 
This determines where the x-axis is positioned. If you wish to show negative values then you should set this to center or you can now (Jul 2016) use an offset x-axis by leaving this property at the default bottom and using the yaxisScaleMax and yaxisScaleMin properties.
Default: bottom
Name: xaxisLinewidth
Description: 
The linewidth used for the x-axis and the x-axis tickmarks.
Default: 1
Name: xaxisColor
Description: 
The color of the x-axis (and its tickmarks.
Default: black
Name: xaxisTickmarks
Description: 
Whether the x-axis tickmarks are shown.
Default: true
Name: xaxisTickmarksLastLeft
Description: 
Whether the last tickmark on the left is displayed.
Default: null
Name: xaxisTickmarksLastRight
Description: 
Whether the last tickmark on the right is displayed.
Default: null
Name: xaxisTickmarksLength
Description: 
The length of the tickmarks.
Default: 3
Name: xaxisTickmarksCount
Description: 
The number of tickmarks that are shown on the x-axis.
Default: null
Name: xaxisLabels
Description: 
An array of the labels to be used on the chart. You can also give this option a string if you prefer and use formatted labels.
Default: An empty array
Name: xaxisLabelsFont
Description: 
The font used to render the labels.
Default: null
Name: xaxisLabelsSize
Description: 
The size of the labels.
Default: null
Name: xaxisLabelsColor
Description: 
The color of the labels.
Default: null
Name: xaxisLabelsBold
Description: 
Whether the labels are bold or not.
Default: null
Name: xaxisLabelsItalic
Description: 
Whether the labels are italic or not.
Default: null
Name: xaxisLabelsOffsetx
Description: 
This allows you finer-grained control in the horizontal direction over the X label positioning if you need it.
Default:  0
Name: xaxisLabelsOffsety
Description: 
This allows you finer-grained control in the vertical direction over the X label positioning if you need it.
Default:  0
Name: xaxisLabelsFormattedDecimals
Description: 
When using formatted labels this is the number of decimals that are applied to the %{value_formatted} macro.
Default:  0
Name: xaxisLabelsFormattedPoint
Description: 
When using formatted labels this is the decimal point character that's used with the %{value_formatted} macro.
Default: .
Name: xaxisLabelsFormattedThousand
Description: 
When using formatted labels this is the thousand separator character that's used with the %{value_formatted} macro.
Default: ,
Name: xaxisLabelsFormattedUnitsPre
Description: 
When using formatted labels these are the units that are prepended to the number with the %{value_formatted} macro.
Default: (an empty string)
Name: xaxisLabelsFormattedUnitsPost
Description: 
When using formatted labels these are the units that are appended to the number with the %{value_formatted} macro.
Default: (an empty string)
Name: xaxisLabelsCount
Description: 
When using formatted labels you can specify how many labels there should be with this property.
Default: null
Name: xaxisLabelsHalign
Description: 
The horizontal alignment of the labels.
Default: center
Name: xaxisLabelsValign
Description: 
The vertical alignment of the labels.
Default: top
Name: xaxisLabelsAngle
Description: 
The angle of the x-axis labels. For example, you could set this to 45 to get angled labels.
Default: 0 (Horizontal)
Name: xaxisLabelsPosition
Description: 
This property controls how the labels are arranged - section for most chart types and edge for Line charts. You probably won't need to change this.
Default: section
Name: xaxisLabelsClass
Description: 
This property allows you to add your own css class to the x-axis labels which you can then use for styling purposes or to make retrieving the span tags easier (the dom elements). If you inspect the labels in your browser's javascript console (you will first need to enable the textAccessiblePointerevents property) you will be able to see the other css classes that are assigned to the labels.
Default: [none]
Name: xaxisLabelsSpecificAlign
Description: 
This determines the alignment of the specific labels. You probably won't need this.
Default: left
Name: xaxisScale
Description: 
If true then an X scale is drawn instead of X labels.
Default: false
Name: xaxisScaleUnitsPre
Description: 
These are units that are prepended to the number.
Default: none
Name: xaxisScaleUnitsPost
Description: 
These are units that are appended to the number.
Default: none
Name: xaxisScaleDecimals
Description: 
The number of decimals used for the X scale. If not specified the scaleDecimals property is used.
Default: null
Name: xaxisScaleFormatter
Description: 
This can be a function that is passed the object and the number and should return a formatted number (formatted as you wish).
function myFormatter(opt)
{
    var obj = opt.object,
        num = opt.number;

    return num + 'F'; // An example of formatting
}
Default: null
Name: xaxisScaleLabelsCount
Description: 
This is a number representing how many X labels there should be when you're using the X scale.
Default: 10
Name: xaxisScaleMin
Description: 
The minimum x-axis value you wish to set.
Default:  0
Name: xaxisScaleMax
Description: 
The maximum x-axis value you wish to set. For example, if you're displaying products sold in a year, you might use 365.
Default: none - must be supplied
Name: xaxisTitle
Description: 
This allows you to specify a title for the x-axis.
Default: none
Name: xaxisTitleSize
Description: 
This allows you to specify a size for the x-axis title.
Default: null
Name: xaxisTitleFont
Description: 
This allows you to specify a font for the x-axis title.
Default: null
Name: xaxisTitleBold
Description: 
This controls whether the x-axis title is bold or not.
Default: null
Name: xaxisTitleItalic
Description: 
This controls whether the x-axis title is italic or not.
Default: null
Name: xaxisTitleColor
Description: 
This controls the color of the x-axis title.
Default: null
Name: xaxisTitleX
Description: 
By giving this you can specifically set the X position of the x-axis title.
Default: null
Name: xaxisTitleY
Description: 
By giving this you can specifically set the Y position of the x-axis title.
Default: null
Name: xaxisTitleOffsetx
Description: 
The horizontal pixel offset that's applied to the title.
Default:  0
Name: xaxisTitleOffsety
Description: 
The vertical pixel offset that's applied to the title.
Default:  0
Name: xaxisTitleHalign
Description: 
The horizontal alignment of the title.
Default: center
Name: xaxisTitleValign
Description: 
The vertical alignment of the title.
Default: top
Name: xaxisTitlePos
Description: 
This is a multiplier (ie a digit usually between 0 and 1) that gets multiplied with the margin to get the Y position of the title.
Default: null

Y-axis properties

Name: yaxis
Description: 
Whether the y-axis is drawn.
Default: true
Name: yaxisPosition
Description: 
Specifies the y-axis position. Can be left or right.
Default: left
Name: yaxisLinewidth
Description: 
The linewidth of the y-axis.
Default: 1
Name: yaxisColor
Description: 
The color of the y-axis.
Default: black
Name: yaxisTickmarks.
Description: 
Whether the y-axis tickmarks are drawn.
Default: true
Name: yaxisTickmarksLength
Description: 
The length of the y-axis tickmarks.
Default: 3
Name: yaxisTickmarksCount
Description: 
This allows you to stipulate how many y-axis tickmarks there are.
Default: null (related to how many labels there are)
Name: yaxisTickmarksLastTop
Description: 
Whether the top-most tickmark is drawn.
Default: null (displayed if the x-axis position warrants it)
Name: yaxisTickmarksLastBottom
Description: 
Whether the bottom-most tickmark is drawn.
Default: null (displayed if the x-axis position warrants it)
Name: yaxisLabelsCount
Description: 
A value that controls how many Y labels there are. This value could formerly be either 1/3/5/10 however now it can be any number.
Default: 5
Name: yaxisLabelsSpecific
Description: 
You can use this option to give your own Y labels (eg ['Low', 'Medium', 'High']. Note: Since March 2013 you may now need to add an extra (optionally) empty element to the array of labels to achieve your desired result.
Default: null
Name: yaxisLabelsPosition
Description: 
This controls how the specific labels are positioned on the y-axis. It does not affect a scale.
Default: edge
Name: yaxisLabelsOffsetx
Description: 
This allows you finer-grained control in the horizontal direction over the Y label positioning if you need it.
Default:  0
Name: yaxisLabelsOffsety
Description: 
This allows you finer-grained control in the vertical direction over the Y label positioning if you need it.
Default:  0
Name: yaxisLabelsFont
Description: 
The font that's used by the y-axis labels.
Default: null
Name: yaxisLabelsSize
Description: 
The size of the y-axis labels.
Default: null
Name: yaxisLabelsColor
Description: 
The color of the y-axis labels.
Default: null
Name: yaxisLabelsBold
Description: 
Whether the y-axis labels are bold or not.
Default: null
Name: yaxisLabelsItalic
Description: 
Whether the y-axis labels are italic or not.
Default: null
Name: yaxisLabelsHalign
Description: 
The horizontal alignment of the y-axis labels.
Default: null
Name: yaxisLabelsValign
Description: 
The vertical alignment of the y-axis labels.
Default: null
Name: yaxisTitle
Description: 
This allows you to specify a title for the y-axis.
Default: none
Name: yaxisTitleSize
Description: 
This allows you to specify a size for the y-axis title.
Default: null
Name: yaxisTitleFont
Description: 
This allows you to specify a font for the y-axis title.
Default: null
Name: yaxisTitleBold
Description: 
This controls whether the y-axis title is bold or not.
Default: null
Name: yaxisTitleColor
Description: 
This controls what color the y-axis title is.
Default: null
Name: yaxisTitleItalic
Description: 
This controls whether the y-axis title is italic or not.
Default: null
Name: yaxisTitlePos
Description: 
This is multiplied with the margin to give the position of the y-axis title.
Default: 0.25
Name: yaxisTitleOffsetx
Description: 
The pixel offset that's added to the y-axis titles X coordinate.
Default:  0
Name: yaxisTitleOffsety
Description: 
The pixel offset that's added to the y-axis titles Y coordinate.
Default:  0
Name: yaxisTitleX
Description: 
By giving this you can specifically set the horizontal position of the y-axis title.
Default: null
Name: yaxisTitleY
Description: 
By giving this you can specifically set the vertical position of the y-axis title.
Default: null
Name: yaxisTitleHalign
Description: 
The horizontal alignment of the y-axis title.
Default:  0
Name: yaxisTitleValign
Description: 
The vertical alignment of the y-axis title.
Default:  0
Name: yaxisTitleAccessible
Description: 
With this property you can control whether the y-axis title is accessible or not.
Default: true
Name: yaxisScale
Description: 
Whether the y-axis scale is displayed or not.
Default: true
Name: yaxisScaleRound
Description: 
Whether the y-axis scale is rounded up or not.
Default: false
Name: yaxisScaleUnitsPre
Description: 
The units that the y-axis is measured in. This string is displayed before the actual number, allowing you to specify values such as $50.
Default: none
Name: yaxisScaleUnitsPost
Description: 
The units that the y-axis is measured in. This string is displayed after the actual number, allowing you to specify values such as 50ms.
Default: none
Name: yaxisScaleMax
Description: 
The optional maximum Y scale value. If not specified then it will be calculated.
Default: null (It's calculated)
Name: yaxisScaleMin
Description: 
The optional minimum Y scale value. If not specified then it will be 0.
Default:  0
Name: yaxisScaleFormatter
Description: 
To allow thoroughly custom formats of numbers in the scale, you can use this option to specify a function that is used by RGraph to format numbers. This function should handle ALL of the formatting. Eg:

function myFormatter(opt)
{
    var num = Number(opt.number) * 5;

    return String(num)
}
obj.set('yaxisScaleFormatter', myFormatter);
Default: null
Name: yaxisScaleRound
Description: 
Whether to round the scale up. eg A maximum value of 59 results in scale to 100.
Default: false
Name: yaxisScaleDecimals
Description: 
The number of decimal places to display for the Y scale.
Default:  0
Name: yaxisScalePoint
Description: 
The character that's used as the decimal point.
Default: .
Name: yaxisScaleThousand
Description: 
The character that's used as the thousand separator.
Default: ,
Name: yaxisScaleInvert
Description: 
Whether the y-axis scale is inverted or not.
Default: false

Color properties

Name: colorsDefault
Description: 
This is the default color of tickmarks that is used if a color isn't given.
Default: #000
Name: colorsBubbleGraduated
Description: 
By default the Bubble chart bubbles are graduated in color. By setting this to false you can disable the gradients and use flat colors.
Default: true
Name: colorsBubbleStroke
Description: 
If you want a stroke around your bubbles (if you're showing a Bubble chart) you can set this to a color.
Default: null

Labels and text properties

Name: labelsAbove
Description: 
If true this will show the values of the points above them.
Default: false
Name: labelsAboveFont
Description: 
The font used to render the text.
Default: null
Name: labelsAboveSize
Description: 
If you're showing the labels above the points, this controls their size.
Default: null
Name: labelsAboveColor
Description: 
The color of the text.
Default: null
Name: labelsAboveBold
Description: 
Whether the labels are bold or not.
Default: null
Name: labelsAboveItalic
Description: 
Whether the labels are italic or not.
Default: null
Name: labelsAboveDecimals
Description: 
If your points have lots of decimals, you use this option to curtail them.
Default:  0
Name: labelsAboveFormatterX
Description: 
If you need to format the X value then you can use this function to do so. An example function to format a DateTime value is:
labelsAboveFormatterX: function (obj, value)
{
    var d = new Date(value);
        date = d.getDate();
        month = d.getMonth();
        year  = d.getFullYear();
    
    return '{1}/{2}/{3}'.format(date, month, year);
},
Default: null
Name: labelsAboveFormatterY
Description: 
If you need to format the X value then you can use this function to do so. An example function to format a DateTime value is:
labelsAboveFormatterY: function (obj, value)
{
    return value;
},
Default: null
Name: labelsAboveOffsetx
Description: 
This allows you finer-grained control in the horizontal direction over the text positioning if you need it.
Default:  0
Name: labelsAboveOffsety
Description: 
This allows you finer-grained control in the vertical direction over the text positioning if you need it.
Default:  0
Name: labelsIngraph
Description: 
An array of labels for the chart that are drawn "inside" the chart. If you have 5 data points then this should have a corresponding number of elements, though there is a shorthand style available.
Default: null
Name: labelsIngraphFont
Description: 
The font that the ingraph labels are rendered in.
Default: null
Name: labelsIngraphSize
Description: 
The size of the ingraph labels.
Default: null
Name: labelsIngraphColor
Description: 
The color of the ingraph labels.
Default: null
Name: labelsIngraphBold
Description: 
Whether the ingraph labels are bold or not.
Default: null
Name: labelsIngraphItalic
Description: 
Whether the ingraph labels are italic or not.
Default: null
Name: labelsIngraphOffsetx
Description: 
This allows you finer-grained control in the horizontal direction over the text positioning if you need it.
Default:  0
Name: labelsIngraphOffsety
Description: 
This allows you finer-grained control in the vertical direction over the text positioning if you need it.
Default:  0
Name: textFont
Description: 
The font used to render the text.
Default: Arial
Name: textColor
Description: 
The color of the labels.
Default: black
Name: textSize
Description: 
The size of the text (in points).
Default: 12
Name: textBold
Description: 
Whether the text is bold or not.
Default: false
Name: textItalic
Description: 
Whether the text is bold or not.
Default: false
Name: textAccessible
Description: 
A 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>
Default: false
Name: textAccessibleOverflow
Description: 
This 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 margins if you wish.
Default: visible
Name: textAccessiblePointerevents
Description: 
This controls whether the dom text responds to mouse based events or not (it sets the pointer-events css property to none).
Default: true
Name: text
Description: 
This allows you to add custom text to your chart if you want to. There's a dedicated page that describes this option here.
Default: null

Margin properties

Name: marginLeft
Description: 
The left margin of the chart, (the margin is where the labels and title are)).
Default: 35
Name: marginRight
Description: 
The right margin of the chart, (the margin is where the labels and title are).
Default: 35
Name: marginTop
Description: 
The top margin of the chart, (the margin is where the labels and title are).
Default: 35
Name: marginBottom
Description: 
The bottom margin of the chart, (the margin is where the labels and title are).
Default: 35

Tickmark properties

Name: tickmarksStyle
Description: 
The style of the tickmarks. Can be: cross, plus, circle, diamond, square or null (no tickmarks). As of August 2014, this can be a location of an image file to use as the tickmarks or a data: URL. See below for details. This property can also be a function which allows you to draw the tickmark yourself - details below.
Default: cross
Name: tickmarksSize
Description: 
The size of the tickmarks.
Default: 3
Name: tickmarksStyleImageHalign
Description: 
This can be left right or center and determines the horizontal alignment of the tickmark.
Default: center
Name: tickmarksStyleImageValign
Description: 
This can be top bottom or center and determines the vertical alignment of the tickmark.
Default: center
Name: tickmarksStyleImageOffsetx
Description: 
After the alignment has been applied, this is added to the X coordinate of the tickmark.
Default:  0
Name: tickmarksStyleImageOffsety
Description: 
After the alignment has been applied, this is added to the Y coordinate of the tickmark.
Default:  0

Title properties

Name: title
Description: 
The title of the chart, if any.
Default: null
Name: titleFont
Description: 
The font that the title is rendered in. If not specified the textFont setting is used (usually Arial).
Default: null
Name: titleSize
Description: 
The size of the title. If not specified the size is usually 4pt bigger than the textSize setting.
Default: null
Name: titleBold
Description: 
Whether the title is bold or not.
Default: null
Name: titleItalic
Description: 
Whether the title is italic or not.
Default: null
Name: titleColor
Description: 
The color of the title.
Default: null
Name: titleX
Description: 
To give the exact X coordinate for the title - use this. This can also be a string like this: "-5" - in which case it's converted to a number and added to the calculated coordinate - allowing you to adjust the calculated coordinate.
Default: null
Name: titleY
Description: 
To give the exact Y coordinate for the title - use this. This can also be a string like this: "-5" - in which case it's converted to a number and added to the calculated coordinate - allowing you to adjust the calculated coordinate.
Default: null
Name: titleHalign
Description: 
The horizontal alignment of the title.
Default: center (can change depending on other options)
Name: titleValign
Description: 
The vertical alignment of the title.
Default: center (can change depending on other options)
Name: titleOffsetx
Description: 
You can use this property to adjust the positioning of the title in the horizontal direction (positive values adjust the title to the right and negative values adjust it to the left).
Default:  0
Name: titleOffsety
Description: 
You can use this property to adjust the positioning of the title in the vertical direction (positive values adjust the title downwards and negative values adjust it upwards).
Default:  0
Name: titleSubtitle
Description: 
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: null
Name: titleSubtitleSize
Description: 
The size of the font used to render the subtitle.
Default: null
Name: titleSubtitleColor
Description: 
The color of the subtitle.
Default: #aaa
Name: titleSubtitleFont
Description: 
The font used to render the subtitle.
Default: null
Name: titleSubtitleBold
Description: 
Whether the subtitle is bold or not.
Default: null
Name: titleSubtitleItalic
Description: 
Whether the subtitle is italic or not.
Default: null
Name: titleSubtitleOffsetx
Description: 
Use this property to adjust the horizontal position of the subtitle.
Default:  0
Name: titleSubtitleOffsety
Description: 
Use this property to adjust the vertical position of the subtitle.
Default:  0

Interactive features properties

Name: tooltipsEffect
Description: 
The effect used for showing tooltips. Possible values are slide fade or none.
Default: slide
Name: tooltipsHotspot
Description: 
This controls the size of the hotspot on the chart for tooltips.
Default: 3
Name: tooltipsHighlight
Description: 
Set this to false if you don't want your charts to be highlighted.
Default: true
Name: tooltipsOverride
Description: 
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
Name: tooltipsFormattedPoint
Description: 
When using formatted tooltip strings this is used as the point when using the %{value_formatted} option.
Default: .
Name: tooltipsFormattedThousand
Description: 
When using formatted tooltip strings this is used as the thousand separator when using the %{value_formatted} option.
Default: ,
Name: tooltipsFormattedDecimals
Description: 
When using formatted tooltip strings this specifies the number of decimals when using the %{value_formatted} option.
Default:  0
Name: tooltipsFormattedUnitsPre
Description: 
When using formatted tooltip strings these units are prepended to the number when using the %{value_formatted} option.
Default: (an empty string)
Name: tooltipsFormattedUnitsPost
Description: 
When using formatted tooltip strings these units are appended to the number when using the %{value_formatted} option.
Default: (an empty string)
Name: tooltipsFormattedKeyColors
Description: 
When using formatted tooltip strings you can give specific colors for the %{key} option to use.
Default: null
Name: tooltipsFormattedKeyColorsShape
Description: 
This is the shape that's used in the tooltip key. It can be square or circle
Default: square
Name: tooltipsFormattedKeyColorsCss
Description: 
By using this property you can add css values to the key color shape that appears in the tooltip key. Note the property name is "color" and not "colors" like previous properties. It should be an object of css properties like this:
tooltipsFormattedKeyColorsCss : {
    border: "1px solid #ddd";
}
Default: null
Name: tooltipsFormattedKeyLabels
Description: 
When using formatted tooltip strings these are the labels that are displayed.
Default: [] (an empty array)
Name: tooltipsFormattedListType
Description: 
With this property you can switch between an unordered list (the default) and an ordered list. Possible values are ul and ol.
Default: ul
Name: tooltipsFormattedListItems
Description: 
This should be a two-dimension array of the list items that are to be shown for all of the tooltips. An example of this property is:
tooltipsFormattedListItems: [
    ['Bill','Jerry','Berty'], // First tooltip
    ['Gill','Carrie','Lucy'], // Second tooltip
    ['Pob','Nobby','Hilda']   // Third tooltip
]
You can use css to style this list - for example:
.RGraph_tooltip ul#rgraph_formatted_tooltips_list li {
    text-align: left;
    color: yellow;
}
Default: null
Name: tooltipsFormattedTableHeaders
Description: 
When showing a table in the tooltips this can be an array of headers for the table. These are added to the tooltip using th tags.
Default: null
Name: tooltipsFormattedTableData
Description: 
This is the data that's added to the table. This is a 3-dimensional array so it's easy to make a mistake. See the example, copy the code from it and then modify it suit. You'll create fewer bugs this way.
Default: null)
Name: tooltipsPointer
Description: 
By default the tooltips have a small triangular pointer that points to the shape that was clicked on. You can turn this off with this property.
Default: true
Name: tooltipsPointerCss
Description: 
If you want any css values applied to the tooltips pointer (a css border, for example) then specify an object containing those values to this property. For example:
tooltipsPointerCss: {
    borderLeft: 'gray 2px solid',
    borderBottom: 'gray 2px solid'
}
Default: null
Name: tooltipsPointerOffsetx
Description: 
This allows you to adjust the vertical position of the tooltips pointer.
Default:  0
Name: tooltipsPointerOffsety
Description: 
This allows you to adjust the vertical position of the tooltips pointer (for example, if you add a border you may need to move it down slightly).
Default:  0
Name: tooltipsPositionStatic
Description: 
The new default (as of August 2020) is for tooltips to be positioned statically and not be dependent on the mouse position. If you don't want this for whatever reason, you can disable it with this setting. When you set it to false tooltips are positioned next to the mouse pointer.
Default: true
Name: tooltipsCss
Description: 
If you want to specify some css that gets applied to all of the tooltips, but don't want to use the RGraph.tooltips.style object (which gets applied to all of the tooltips on the page for every chart) you can use this property to give some per-object css for the tooltips. These are css styles that get applied to all of the tooltips for the specific object only. It should look like this:
tooltipsCss: {
    fontFamily: 'Verdana',
    fontSize: '20pt'
}
Default: null
Name: tooltipsCssClass
Description: 
This is the name of the css class the chart uses.
Default: RGraph_tooltip
Name: tooltipsOffsetx
Description: 
This property allows you to shift the tooltips left or right.
Default:  0
Name: tooltipsOffsety
Description: 
This property allows you to shift the tooltips up or down.
Default:  0
Name: tooltipsHotspotIgnore
Description: 
This can be a number of things and can be used to ignore certain tooltip hotspots - which can allow charts to the rear to be clickable. There's an example of this in the download archive called pie-tooltipshotspotignore.html. You can use the transparent color to allow the rear chart to be seen in such a case. It can be:
  • A single boolean value (ie true or false) to enable or disable all of the hotspots - true means the hotspot will be ignored
  • A single number (the zero-indexed number corresponding to the hotspot to ignore)
  • An array of numbers (the numbers are the indexes of hotspots to ignore)
  • An array of boolean true or false values - the position of these values correspond to the index(es) of the segments to ignore (for example [false, false, true, false, false] - true means the corresponding hotspot will be ignored)
Default: null
Name: crosshairs
Description: 
If true, you will get a crosshair centering on the current mouse position.
Default: false
Name: crosshairsLinewidth
Description: 
This controls the linewidth of the crosshairs.
Default: 1
Name: crosshairsColor
Description: 
The color of the crosshairs.
Default: #333
Name: crosshairsCoords
Description: 
If true, this will show the coordinates that the crosshairs are currently over.
Default: false
Name: crosshairsCoordsFixed
Description: 
If true, this makes the coordinates static (attached), instead of following the pointer around.
Default: false
Name: crosshairsCoordsLabelsX
Description: 
Instead of X and Y, you can specify more meaningful labels.
Default: X
Name: crosshairsCoordsLabelsY
Description: 
Instead of X and Y, you can specify more meaningful labels.
Default: Y
Name: crosshairsCoordsFormatterX
Description: 
This can be a function with which you can format the value to appear just as you want. Simply return the value that you wish to be displayed. The single argument is an object that has two properties: object (which is the chart object) and value (which is the X value).
Default: null
Name: crosshairsCoordsFormatterY
Description: 
This can be a function with which you can format the value to appear just as you want. Simply return the value that you wish to be displayed. The single argument is an object that has two properties: object (which is the chart object) and value (which is the Y value).
Default: null
Name: crosshairsHline
Description: 
This determines whether the horizontal crosshair line is shown.
Default: true
Name: crosshairsVline
Description: 
This determines whether the vertical crosshair line is shown.
Default: true
Name: crosshairsSnapToScale
Description: 
If set to true the horizontal grid line will snap to the scale values.
Default: false
Name: contextmenu
Description: 
An array of context menu items. More information about context menus is here.
Default: An empty array
Name: adjustable
Description: 
Whether the chart can be adjusted by dragging the points on the chart around.
Default: false
Name: adjustableOnly
Description: 
This should be an array of values that determine whether a point is adjustable or not. A true value for when it is, a false value for when it's not.
Default: null
Name: annotatable
Description: 
Whether annotations are enabled for the chart (ie you can draw on the chart interactively.
Default: false
Name: annotatableColor
Description: 
If you do not allow the use of the palette, then this will be the only color allowed for annotations.
Default: black
Name: annotatableLinewidth
Description: 
This is the linewidth of the annotations.
Default: 1

Line properties

Name: line
Description: 
Whether to show a connecting line (like in the sixth example).
Default: false
Name: lineColors
Description: 
The colors of the lines connecting the tickmarks.
Default: ['green', 'red']
Name: lineShadowColor
Description: 
The color of the shadow of the line (if any).
Default: rgba(0,0,0,0)
Name: lineShadowOffsetx
Description: 
The horizontal offset of the shadow.
Default: 3
Name: lineShadowOffsety
Description: 
The vertical offset of the shadow.
Default: 3
Name: lineShadowBlur
Description: 
The severity of the shadows blurring effect.
Default: 2
Name: lineStepped
Description: 
Like the Line chart, Scatter chart lines can be stepped by setting this to true.
Default: false
Name: lineLinewidth
Description: 
This can be either a number or an array of numbers (for multiple lines) and controls the linewidth that is used for the lines.
Default: 1
Name: lineDash
Description: 
With this setting you can control the linedash setting so your lines can be dashed (or dotted).

Note: Browser support is limited (but growing) for dashed/dotted lines - so depending on your browser you may see just a solid line.
Default: null

Trend line properties

Name: trendline
Description: 
If you want it to RGraph can generate a "best-fit" trend line for your data. This can be both a boolean or an array of boolean values for when you have multiple datasets.
Default: false
Name: trendlineColors
Description: 
Use this property to specify either a single color or an array of colors for the trend line(s).
Default: [gray]
Name: trendlineLinewidth
Description: 
Use this property to specify the linewidth of the trend line(s). It can be a single number or an array of numbers if you have multiple datasets.
Default: 1
Name: trendlineMargin
Description: 
Use this property to specify the margin of the trend line(s). It can be a single number or an array of numbers if you have multiple datasets.
Default: 25
Name: trendlineDashed
Description: 
If true then the trend lines on the chart will be dashed.
Default: true
Name: trendlineDotted
Description: 
If true then the trend lines on the chart will be dotted,
Default: false
Name: trendlineDashArray
Description: 
If you want to give your own style of dashes then you can with this. It should be an array containing numbers - alternating between the length of a dash and the length of a gap after the dash.
Default: null
Name: trendlineClipping
Description: 
If set to false then the chart will not be clipped to the area that the tickmarks are located in. This means that the trend line will cover the whole of the chart area (albeit with a small margin and you can turn this off with the trendlineMargin property).
Default: null

Bubble properties

Name: bubbleMin
Description: 
The minimum value that the bubble represents
Default:  0
Name: bubbleMax
Description: 
The maximum value that the bubble represents
Default: null
Name: bubbleWidth
Description: 
The maximum width of a bubble on the chart
Default: null
Name: bubbleData
Description: 
The bubble values for each of the points on the chart
Default: null
Name: bubbleLinewidth
Description: 
Allows you to set the linewidth of the stroke around the bubbles if you have one.
Default: 1
Name: bubbleShadow
Description: 
Whether shadows for the bubbles are enabled or not.
Default: false
Name: bubbleShadowColor
Description: 
The color of the bubble shadows.
Default: #aaa
Name: bubbleShadowOffsetx
Description: 
The horizontal offset for the bubble shadows.
Default: 2
Name: bubbleShadowOffsety
Description: 
The vertical offset for the bubble shadows.
Default: 2
Name: bubbleShadowBlur
Description: 
The extent of the blurring effect for the bubble shadows.
Default: 3

Lasso properties

Name: lasso
Description: 
The Lasso feature allows you to select points on your chart with your mouse. You can draw rectangles around them and then use the callback function to integrate into your own code.
Default: false
Name: lassoStroke
Description: 
The color of the outline of the square highlight area.
Default: #006
Name: lassoFill
Description: 
The color of the fill of the square highlight area.
Default: #0064
Name: lassoLinewidth
Description: 
The linewidth of the outline of the square highlight area.
Default: 1
Name: lassoHighlightStroke
Description: 
When a point on the chart is highlighted - this is the color of the stroke.
Default: transparent
Name: lassoHighlightFill
Description: 
When a point on the chart is highlighted - this is the color of the fill.
Default: red
Name: lassoHighlightLinewidth
Description: 
When a point on the chart is highlighted - this is the linewidth of the stroke.
Default: 1
Name: lassoCallback
Description: 
When an area is highlighted this function is called - allowing you to call your own code. The function is passed a state object and you can access the state.points property to get a list of datasets/indexes of points which are highlighted. For example:
// ...
lassoCallback: function (state)
{
    // You can access the state.points array to get the points which are highlighted
}
// ...
Default: null
Name: lassoClearCallback
Description: 
Another callback function which is called when the lasso areas are cleared. Note that this event can be called multiple times.
Default: null
Name: lassoPersist
Description: 
This controls whether the lasso data (the selected areas and points) is persisted across page refreshes or not. By default persistence just uses the window.localStorage variable to store information.
Default: false
Name: lassoPersistLocal
Description: 
By default, persistence uses the window.localStorage variable to store the data. If you use the lassoPersistSave and lassoPersistLoad properties to store data somewhere else you might not want this to occur - so, using this property, you can turn it off.
Default: true
Name: lassoPersistSave
Description: 
Using this property you can integrate the loading and saving into your own backend software. For example, by using this function you can make an ajax call to save the persistence information to your server. For example:
// ...
lassoPersistSave: function (state)
{
    // You can access the state.points array to get the points which are highlighted
}
// ...
Default: null
Name: lassoPersistLoad
Description: 
Complementing the above property, by using this property you can integrate the loading and saving into your own backend software. For example, by using this function you can make an ajax call to load the persistence information from your server. For example:
// ...
lassoPersistLoad: function ()
{
    // Load the persistence data here and return it

    // return data;
}
// ...
Default: null

Key properties

The key properties are documented on the key documentation page.

Marimekko properties

Name: marimekkoLinewidth
Description: 
This is the linewidth of the stroke that's used around the segments.
Default: 15
Name: marimekkoColors
Description: 
An array of colors that are used for the segments on the chart.
Default: ['#faa', '#afa', '#aaf', '#ffa', '#faf', '#aff']
Name: marimekkoColorsStroke
Description: 
The color of the stroke that's used on the chart.
Default: transparent
Name: marimekkoColorsSequential
Description: 
By default, the colors that you give with the marimekkoColors property are used in order, for each bar. With this property set to true though the colors are used in the order that you give across the whole set of bars.
Default: false
Name: marimekkoLabels
Description: 
Use this property to specify an array of labels which are placed above the bars in the top margin. This can either be an array of simple strings, an array of strings that use substitution macros or a string that uses substitution macros. This last option is probably the most useful option. Read the formatted labels documentation for more information on this last option.
Default: null
Name: marimekkoLabelsColor
Description: 
The color of the labels. It falls back to the textColor property.
Default: null
Name: marimekkoLabelsSize
Description: 
The size of the labels. It falls back to the textSize property.
Default: null
Name: marimekkoLabelsFont
Description: 
The font that's used for the labels. It falls back to the textFont property.
Default: null
Name: marimekkoLabelsBold
Description: 
Whether the labels are bold or not. It falls back to the textBold property.
Default: null
Name: marimekkoLabelsItalic
Description: 
Whether the labels are italic or not. It falls back to the textItalic property.
Default: null
Name: marimekkoLabelsOffsetx
Description: 
If you want to adjust the position of the labels slightly in the horizontal direction you can do so with this property.
Default:  0
Name: marimekkoLabelsOffsety
Description: 
If you want to adjust the position of the labels slightly in the vertical direction you can do so with this property.
Default:  0
Name: marimekkoLabelsFormattedDecimals
Description: 
When using formatted labels this is the number of decimals that are applied to the %{value_formatted} macro.
Default:  0
Name: marimekkoLabelsFormattedPoint
Description: 
When using formatted labels this is the decimal point character that's used with the %{value_formatted} macro.
Default: .
Name: marimekkoLabelsFormattedThousand
Description: 
When using formatted labels this is the thousand separator character that's used with the %{value_formatted} macro.
Default: ,
Name: marimekkoLabelsFormattedUnitsPre
Description: 
When using formatted labels these are the units that are prepended to the number with the %{value_formatted} macro.
Default: [none]
Name: marimekkoLabelsFormattedUnitsPost
Description: 
When using formatted labels these are the units that are appended to the number with the %{value_formatted} macro.
Default: [none]
Name: marimekkoLabelsIngraph
Description: 
This can be true or false and determines whether labels are drawn inside the bars - showing the value.
Default: false
Name: marimekkoLabelsIngraphColor
Description: 
This is the color of the ingraph labels. It defaults to the textColor property.
Default: null
Name: marimekkoLabelsIngraphSize
Description: 
This is the size of the ingraph labels.
Default: 10
Name: marimekkoLabelsIngraphFont
Description: 
This is the font that's used for the ingraph labels. It defaults to the textFont property.
Default: null
Name: marimekkoLabelsIngraphBold
Description: 
Whether the labels are bold or not. It defaults to the textBold property.
Default: null
Name: marimekkoLabelsIngraphItalic
Description: 
Whether the labels are italic or not. It defaults to the textItalic property.
Default: null
Name: marimekkoLabelsIngraphUnitsPre
Description: 
Units which are appended to the label.
Default: [none]
Name: marimekkoLabelsIngraphUnitsPost
Description: 
Units which are prepended to the label.
Default: [none]
Name: marimekkoLabelsIngraphPoint
Description: 
The character(s) used as the decimal point.
Default: .
Name: marimekkoLabelsIngraphThousand
Description: 
The character(s) used as the thousand seperator.
Default: ,
Name: marimekkoLabelsIngraphDecimals
Description: 
The number of decimals that are displayed on labels.
Default: 0
Name: marimekkoLabelsIngraphOffsetx
Description: 
If you want to adjust the position of the labels slightly in the horizontal direction you can do so with this property.
Default: 0
Name: marimekkoLabelsIngraphOffsety
Description: 
If you want to adjust the position of the labels slightly in the vertical direction you can do so with this property.
Default: 0
Name: marimekkoLabelsIngraphBackgroundFill
Description: 
The fill color for the background of the labels.
Default: #fffa
Name: marimekkoLabelsIngraphBackgroundStroke
Description: 
The stroke color for the background of the labels.
Default: transparent
Name: marimekkoLabelsIngraphSpecific
Description: 
This property can be used to specify the exact labels that you want to appear on the chart. You can specify text as well as numbers if you wish.
Default: null

Miscellaneous properties

Name: highlightStyle
Description: 
By 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. It's passed the shape object as an argument. As of version 5.23 you can also set this to invert as well. If you do this on a dark background you may find that you need to change the highlightFill color setting as well.
Default: null
Name: boxplotWidth
Description: 
This stipulates the default width of boxes. For more on boxplots, see here.
Default: 10
Name: boxplotCapped
Description: 
This stipulates whether the boxplot will have caps on the end of the whiskers. This could be useful if you're creating a stock chart for example. For more on boxplots, see here.
Default: true
Name: clearto
Description: 
This is used in animations and effects as the default color to use when clearing the canvas.
Default: null
Name: outofbounds
Description: 
If you've set a yaxisScaleMax but you still want to see marks drawn that go above this maximum then you'll need to set this property to true.
Default: false
Name: horizontalLines
Description: 
With this property you can add horizontal lines to your chart. This feature was initially designed with adding an average line indicator in mind but can be used to indicate any value with any label. The value of this property should be an array of objects and each object can consist of the following:
  • value: The value you want the line positioned at or the keyword average (default: average)
  • color: The color of the line (default: #666)
  • dashed: Whether the line is dashed or not (default: true)
  • dotted: Whether the line is dotted or not (default: false)
  • linewidth: The linewidth of the line (default: 1)
  • label: this is The label that appears above (by default) the line. If you don't want a label you can set this to an empty string. default: Average (%{value})
  • labelPosition: This can be a string that consists of the following keywords: left/center/right/left-margin/right-margin top/bottom (default: top right)
  • labelFont: The font that the label is drawn in (default: [the same as the textFont property])
  • labelColor: The color that the label is drawn in (default: #666)
  • labelSize: The size of the label (in points) (default: 4 points less than the textSize setting)
  • labelBold: Whether the label is bold or not (default: null [falls back to the textBold setting])
  • labelItalic: Whether the label is italic or not (default: null [falls back to the textItalic setting])
  • labelValueDecimals: How many decimals are shown on the number. (default: 2)
  • labelValuePoint: The character used as the decimal point. (default: .)
  • labelValueThousand: The character used as the thousand separator charactor.(default: ,)
  • labelValueUnitsPre: This string is prended to the number. (default: [an empty string])
  • labelValueUnitsPost: This string is appended to the number. (default: [an empty string])
  • labelOffsetx: The horizontal offset that's applied to the X coordinate. (default: 0)
  • labelOffsety: The vertical offset that's applied to the Y coordinate. (default: 0)
  • labelValueFormatter: This function handles ALL of the formatting of the number. (default: null)
Here's an example:
obj.set('horizontalLines', [
    {
        value: 'average',
        dashed: true,
        labelPosition:'left bottom'
    },
    {
        value: 10.48,
        label:'Value (%{value})',
        labelValueDecimals: 2,
        labelValueThousand: ',',
        labelValuePoint:'.',
        labelValueUnitsPre:'',
        labelValueUnitsPost:''
        //labelValueFormatter: function (opt)
        //{
        //    return opt.number;
        //}
    }
]);
Default: null
Name: responsive
Description: 
This option is new to the July 2023 release (v6.13) and allows you to inline the responsive configuration instead of appending it on to the end of the object it as a function. The documentation and demo pages have been updated to use this new option. You can read more about the responsive feature by reading the responsive configuration page.
Default: null

Methods

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


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


obj.getShape(event)

This function makes it easier to get hold of which point on the Scatter chart has been clicked or hovered over. It returns an object that has the following properties:

object The chart object
x The X coordinate
y The Y coordinate
dataset The zero-indexed dataset (the Scatter chart supports multiple datasets).
index The zero-indexed index of the point.
sequentialIndex The zero-indexed sequential index of the point. For example, on a chart where there are three datasets of three points each - this goes from 0 up to 8.
tooltip If a tooltip is associated with this point this will be it.id: strings are expanded for you (where the tooltip text is retrieved from the html tag with the matching ID).
Example usage is:
<script>
    scatter.canvas.onmousemove = function (e)
    {
        var canvas  = e.target;
        var obj     = canvas.__object__;
        var shape   = obj.getShape(e);

        if (shape) {
            obj.path(
                'b a % % 5 0 6.29 f red',
                shape.x, shape.y
            );
        }
    }
</script>

In boxplots the shape object is slightly different:

object The chart object
x The X coordinate
y The Y coordinate
width The width of the bar
height The height of the bar
dataset The zero-indexed dataset. Scatter charts can have multiple datasets and this indicates the dataset index.
index The zero-indexed index of the box.
sequentialIndex The zero-indexed sequential index of the box.
tooltip If a tooltip is associated with this box this will be it. id: strings are expanded for you (where the tooltip text is retrieved from the html tag with the matching ID).
Example usage is:
<script>
    scatter.canvas.onclick = function (e)
    {
        RGraph.redraw();
    
        var canvas = e.target,
            obj    = canvas.__object__,
            shape  = obj.getShape(e);

        if (shape) {
            obj.path(
                'lc square lj square b r % % % % f red',
                shape.x, shape.y, shape.width, shape.height
            );
        }
    }
</script>

obj.getXValue(mixed)

This method can be used to get the X value at a particular point or at the mouse coordinates, based on the X maximum value that is being used. Not simply the coordinates of the mouse. The argument can either be an event object (for use in event listener functions) OR a two-element array consisting of the X and Y coordinates (ie when you're not necessarily in an event listener). It returns null if the mouse or coordinates are in the margin areas.


obj.getYValue(mixed)

This method can be used to get the Y value at a particular point or at the mouse coordinates, based on the scale that is in use. Not simply the coordinates of the mouse. The argument can either be an event object (for use in event listener functions) OR a two-element array consisting of the X and Y coordinates (ie when you're not necessarily in an event listener). It returns null if the mouse or coordinates are in the margin areas.


obj.getYCoord(value)

This method can be used to get an appropriate Y coordinate for a value when you're doing custom drawing on the chart. It returns the coordinate for the max/min value if the given number is out of range.


obj.getXCoord(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 given number is out of range. If you're using a Date/Time chart with the min and max set to Date/Time strings you can also pass this function a Date/Time string eg:

obj.getXCoord('2013-06-12T15:14:16');

obj.on(event, function)

This method can be used to set an event listener on an object. It operates similarly to the jquery on function. The first argument is the event that you wish to attach to and the second is the handler function. For example:

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

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

<script>
    new RGraph.Scatter({
        id: 'cvs',
        data: [ [12,35],[23,53],[35,35],[45,58],[56,55],[86,86] ],
        options: {
            xaxisScaleMax: 100
        }
    }).on('draw', function (obj)
    {
        // Put your draw event code here

    }).on('click', function (e, shape)
    {
        // Put your click event code here
    }).draw();
</script>
RGraph.Scatter.random(object)

This method can be used to create a random set of data if you're creating an example chart and don't want to manually generate lots of dummy data. The only (optional) argument is an object which can contain the following keys:

Example:
<script>
    var data = RGraph.Scatter.random({
        count: 50,
        xmax:  365,
        ymax:  100,
        tooltip: true
    });
</script>
obj.exec(function)

The exec function is documented here.

obj.responsive(configuration)

The responsive function helps your charts respond to different browser window sizes and screen resolutions. For example, for smaller screens, you might want to have angled labels or show shorter versions of them completely.

Update: There is now the responsive configuration option available to you and this is now the preferred method of configuration.

The responsive function and configuration option are documented on their own page here.

Box/Whisker (candlestick) plots

Instead of a single Y value, you can specify an array of 5, 6, 7 or 8 values, which will be used to make a box plot (also known as a candlestick plot). These values are (in order):

<script>
    new RGraph.Scatter({
        id: 'scatter8',
        data: [
            [10,[1,1,16,24,24, 'red', 'green']],
            [105,[5,10,15,25,25, 'red', 'green']],
            [125,[10,15,25,35,45, 'red', 'green']],
            [325,[10,15,25,35,45, 'red', 'green', 30]]
        ],
        options: {
            title: 'An example of a boxplot',
            xaxisLabels: ['Q1', 'Q2', 'Q3', 'Q4'],
            xaxisScaleMax: 365,
            yaxisScaleMax: 50,
            boxplotWidth: 12 // the default width
        }
    }).draw();
</script>

Capped ends

For better compatibility with stock charts, you can now specify that the horizontal lines at the ends of the box plot are not shown with the boxplotCapped option.

Specific points for labels on the x-axis

Instead of a simple string that's used as the label, each entry of the labels array can be a two-element array consisting of the label and the X value that the label should be placed at. For example:

scatter.set({
    xaxisLabels:[
        ['Quarter 1', 0],
        ['Quarter 2', 90],
        ['Quarter 3', 181],
        ['Quarter 4', 273]
    ]
});

Custom tickmarks

If none of the available tickmark styles are suitable, you can specify a function that draws the tickmark, enabling you to draw the tickmark yourself. For example:

<script>
    //
    // The function that is called once per tickmark, to draw it
    // 
    // @param object obj           The chart object
    // @param object data          The chart data
    // @param number x             The X coordinate
    // @param number y             The Y coordinate
    // @param number xValue        The X value
    // @param number yValue        The Y value
    // @param number xMax          The maximum X scale value
    // @param number yMax          The maximum Y scale value
    // @param string color         The color of the tickmark
    // @param number dataset       The index of the data (which starts at zero
    // @param number index         The index of the data in the dataset (which starts at zero)
    //
    // You can set the function in the regular chart configuration:
    //
    tickmarksStyle: function (obj, data, x, y, xValue, yValue, xMax, yMax, color, dataset, index)
    {
        // Draw your custom tick here
    },
    
    //
    // Or you can set it seperately using the obj.set() function:
    //
    line.set('tickmarksStyle', function (obj, data, x, y, xValue, yValue, xMax, yMax, color, dataset, index)
    {
        // Draw your custom tick here
    });
</script>

As of August 2014 you can also specify an image to use as a tickmark. Various styles of URL are supported:

obj.set({tickmarks: 'image:foo.png'});     // Starts with image: prefix
obj.set({tickmarks: '/images/foo.png'});   // Starts with a /
obj.set({tickmarks: '../images/foo.png'}); // Starts with ../
obj.set({tickmarks: 'data: ...'});         // Starts with data: (for inline images)
obj.set({tickmarks: 'images/foo.png'});    // Starts with images/

Note about colors and the key

If you're using a key you may need to set lineColors to allow it to use the correct colors. For example:

obj.set('lineColors', ['red','green','blue']);

Note about the crosshairs event

With the Scatter chart you can use the crosshairs custom event to pull out the crosshair coordinates like this (the coordinates are only available if you have them displayed):

function myFunc (obj)
{
    var xCoord = obj.canvas.__crosshairs_x__;
    var yCoord = obj.canvas.__crosshairs_y__;
}
RGraph.addCustomEventListener(obj, 'crosshairs', function ()
{
    // Handle the event here
});

Adding a trend line to your chart

Since version 5.22 RGraph has supported trend lines on the Scatter chart. This is as easy as setting the trendline option to true and RGraph will calculate the best-fit line for your data. The Scatter chart example linked at the top of the page is using the trendline option and there's also an example shown below:

<script>
    new RGraph.Scatter({
        id: 'cvs',
        data: [[1,56],[2,45],[3,48],[4,65],[5,66],[6,70],[7,71],[8,69],[9,75],[8,76]],
        options: {
            yaxisScaleMax:100,
            yaxisScaleMin:40,
            xaxisScaleMax: 10,
            xaxisLabels: ['A','B','C','D','E','F','G'],
            
            trendline: true,
            trendlineColor: 'red',
            trendlineDashed: false
        }
    }).draw();
</script>

There are a few ways to configure the lines which you can see in the trend line section of the api documentation.

Note about the data_arr array

Sometimes you may wish to view your data as one big array, instead of one array per dataset. In this case, the obj.data_arr is available. This is one long array containing all of the individual data points. Remember that with the Scatter chart the data points themselves are arrays/objects of X/Y/color/tooltip etc information.

DateTime based charts

Instead of using a number as the X coordinate, you can use a DateTime value instead. Likewise, you can use the same style Date/Time values as the xaxisScaleMin and xaxisScaleMax values. The underlying Date/Time parsing uses the Date.parse function (via the RGraph.parseDate function) so you can use values such as: 2012-01-01 00:00:00 There's an example of a Date/Time chart in the download archive (scatter-date-time-values.html)

 

Update (version 5.25) - Moment.js added to RGraph
The Date/Time parsing in RGraph is versatile and recognises a lot of formats. The Moment.js library however is a dedicated library for parsing and manipulating dates and times. From version 5.25 the Moment.js library is bundled with RGraph. You can include it in your page by including the file RGraph.common.moment.js in your page. Once you've done that you can use the Moment.js api to manipulate dates as you require. Here's a very simplistic example of using Moment.js to set the minimum and maximum values of a Scatter chart:

new RGraph.Scatter({
    id: 'cvs',
    data: data,
    options: {
        tickmarksSize: 10,
        xaxisTickmarksCount: 7,
        xaxisScaleMin: moment('2020-01-01'),
        xaxisScaleMax: moment('2020-01-01').add(1, 'year'),
        backgroundGridVlines: false,
        marginRight: 100
    }
}).draw();

The html tag to include the Moment.js library in your page is this:

    <script src="RGraph.moment.js"></script>

 

Bubble charts

The RGraph Scatter chart can show Bubble charts natively. From version 5.26 the way you make Bubble charts has changed and been integrated into the Scatter chart.

There's an example of the code that's necessary to show this type of chart shown below. The various properties are:

Name: bubbleMin
Description: 
The minimum value that the bubble represents
Default:  0
Name: bubbleMax
Description: 
The maximum value that the bubble represents
Default: null
Name: bubbleWidth
Description: 
The maximum width of a bubble on the chart
Default: null
Name: bubbleData
Description: 
The bubble values for each of the points on the chart
Default: null
Name: bubbleLinewidth
Description: 
Allows you to set the linewidth of the stroke around the bubbles if you have one.
Default: 1
Name: bubbleShadow
Description: 
Whether shadows for the bubbles are enabled or not.
Default: false
Name: bubbleShadowColor
Description: 
The color of the bubble shadows.
Default: #aaa
Name: bubbleShadowOffsetx
Description: 
The horizontal offset for the bubble shadows.
Default: 2
Name: bubbleShadowOffsety
Description: 
The vertical offset for the bubble shadows.
Default: 2
Name: bubbleShadowBlur
Description: 
The extent of the blurring effect for the bubble shadows.
Default: 3
<script>
    // Create and configure the Scatter chart
    scatter = new RGraph.Scatter({
        id: 'cvs',
        data: [
            [30,15,  'red',   'Red bubble tooltip'],
            [60,5,   'blue',  'Blue bubble tooltip'],
            [90,8,   'pink',  'Pink bubble tooltip'],
            [120,19, 'green', 'Green bubble tooltip'],
            [150,14, 'gray',  'Gray bubble tooltip'],
            [50,12,  'red',   'Red bubble tooltip'],
            [180,24, 'gray',  'Gray bubble tooltip'],
            [250,21, 'black', 'Black bubble tooltip']
        ],
        options: {
            xaxisScaleMax: 365,
            xaxisLabels: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
            textSize:14,
            backgroundGridVlines: false,
            backgroundGridBorder: false,
            xaxisTickmarks:false,
            yaxisTickmarks:false,
            xaxisLinewidth: 2,
            yaxisLinewidth: 2,
            tooltipsHotspot: 10,
            title: 'A bubble chart',
            titleBold: true,
            titleSize: 16,
            titleY: '-5',
            
            bubbleMin: 0,
            bubbleMax: 100,
            bubbleWidth: 50,
            bubbleData: [60,60,70,80,90,84,86,87]
        }
    }).draw().on('mouseout', function (e)
    {
        RGraph.hideTooltip();
        RGraph.redraw();
    });
</script>

 

The Lasso feature

View example on CodePen

The Lasso feature is new in version 6.13 - it allows you to select points on your Scatter chart and highlight them. There are a number of properties that are available to you that allow you to customise that appearance and how the feature behaves (for example a callback function so that you can integrate it into your existing code along with persistence, custom persistence load/save functions and appearance customisation). You can read the property descriptions here.

Note: There's an obj.clearLassoState() function that you can use if you want to clear the current selections. You'll need to call RGraph.redraw() after using this function. For example:

<button onclick="myScatter.clearLassoState(); RGraph.redraw();">Reset the canvas</button>

Here's a full example:

<script>    
    data = [
        [10,1],[10,2],[10,3],[10,4],[10,5],
        [20,1],[20,2],[20,3],[20,4],[20,5],
        [30,1],[30,2],[30,3],[30,4],[30,5],
        [40,1],[40,2],[40,3, 'red', 'Hello!'],[40,4],[40,5],
        [50,1],[50,2],[50,3],[50,4],[50,5],
        [60,1],[60,2],[60,3],[60,4],[60,5]
    ];
    
    // Create and configure the Scatter chart
    scatter = new RGraph.Scatter({
        id: 'cvs',
        data: data,
        options: {
            lasso: true,
            //lassoStroke: '#006',
            //lassoFill: '#f006',
            //lassoLinewidth: 1,
            //lassoHighlightLinewidth: 2,
            //lassoHighlightStroke: '#0000',
            //lassoHighlightFill: 'red',
            
            //This callback is called what points are cleared
            //
            //lassoClearCallback: function (state)
            //{
            //    $c(state);
            //},
            
            // When points are selected - this callback function
            // is called
            //
            //lassoCallback: function (state)
            //{
            //    //$c(state);
            //},
            
            // Whether to enable persistence or not. If nothing
            // else is specified then the state information is
            // stored in the window.localStorage variable
            lassoPersist: true,
            
            // Store the state information in the browser-based
            // window.localStorage variable
            lassoPersistLocal: true,
    
            //lassoPersistSave: function (state)
            //{
            //    // Store the state information (for example,
            //    // in a database). The state information is
            //    // in the form of a JSON object.
            //
            //    console.log(state);
            //},
            //lassoPersistLoad: function ()
            //{
            //    // Get the data (for example, from a database,
            //    // and return it (it should be a valid JavaScript
            //    // object).
            //    //
            //    // return state;
            //},
    
            xaxisScaleMax: 365,
            backgroundGridVlines: false,
            backgroundGridBorder: false,
            xaxis: false,
            yaxis: false,
            tickmarksStyle: 'circle',
            tickmarksSize: 8,
        }
    }).draw();
</script>

Also, you can double-click on a selection rectangle that you've added to remove it. And you can double click on an empty area of the canvas to get rid of all of the selection rectangles.

Marimekko charts

[No canvas support]

The RGraph Scatter chart now (v6.14+) has the ability to create Marimekko charts. These could be likened to Histogram charts or stacked Bar charts because of the way that they present data. Each stack of segments can take up an arbitrary amount of space depending on the proportion of the X value. The array of Y values that you provide is then organised much like a stacked Bar chart with the values converted to percentages so the total Y value adds up to 100%. The code that creates the chart that's shown here is below.

<script src="RGraph.common.core.js" ></script>
<script src="RGraph.common.dynamic.js" ></script>
<script src="RGraph.common.tooltips.js" ></script>
<script src="RGraph.scatter.js" ></script>

<script>
    // Use the dedicate Marimekko class to create the chart
    new RGraph.Scatter.Marimekko({
        id: 'cvs',
        data: [], // The Marimekko data is given as a property instead of here
        options: {
            
            // The Marimekko data
            marimekkoData:[
                [5,[4,8,6,6]],
                [3,[4,5,1,1]],
                [6,[9,6,3,2]],
                [4,[8,5,2,3]]
            ],
            marimekkoLabels: ['John','Larry','Peter','Barry'],
            marimekkoLabelsIngraph: true,
            marimekkoLabelsIngraphUnitsPost: '%',
            marimekkoTooltips: '%{property:marimekkoLabels[%{dataset}]} on %{property:days[%{index}]}',

            days: ['Monday','Tuesday','Wednesday','Thursday'],
            marginLeft: 80,
            tooltipsCss: {
                fontSize: '20pt'
            },
            xaxisScale: true,
            xaxisScaleUnitsPost: '%'
        }
    }).draw().responsive([
        {maxWidth:null,width:700,height:350,options:{textSize: 20,marimekkoLabelsIngraphSize:14},parentCss:{'float':'right', textAlign: ''}},
        {maxWidth:750,width:400,height:200,options:{textSize: 10, marimekkoLabelsIngraphSize:10},parentCss:{'float':'none', textAlign: 'center'}}
    ]);
</script>

Events

RGraph supports custom events that allow you to easily add interactivity to your charts if required. The following events are available:

For example:
new RGraph.Scatter({
    id: 'cvs',
    data: [[5,3],[6,5],[4,8]],
    options: {
    }
}).on('draw', function (obj)
{
    console.log('The draw event has fired');
    
}).draw();

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

    new RGraph.Scatter({
        id: 'cvs',
        data: [[5,5],[10,10],[15,15],[20,20]],
        options: {
            xaxisScaleMax: 90
        }
    }).trace({frames: 60}, myCallback)
</script>