The drawing API Y axis object

The drawing API Y axis object which can be added to your charts to give them extra Y axes. You can add any number of extra Y axes to your chart as you need them.

[No canvas support]

The Y axis object allows you to have extra Y axes in your chart. Formerly this was an independent function but it's now been converted to a drawing API object. This means that it's easier to use and has added interactivity options - such as mousemove and click events and tooltips.


Usage example

<script>
    bar = new RGraph.Bar({
        id: 'cvs',
        data: [[1,2,8],[3,8,7],[9,6,5],[3,5,8],[5,6,6],[1,5,8],[4,8,6]],
        options: {
            backgroundGridVlines: false,
            backgroundGridBorder: false,
            hmargin: 5,
            axes: false,
            xaxisLabels: ['Mar','Apr','May','Jun','Jul','Aug','Sep'],
            yaxisLabels: false,
            marginLeft: 195,
            marginTop: 35,
            colors: [
                'Gradient(green:#0c0)',
                'Gradient(red:#c00)',
                'Gradient(blue:#00c)'
            ],
            tooltips: [
                'James','Jenna','Karl',
                'James','Jenna','Karl',
                'James','Jenna','Karl',
                'James','Jenna','Karl',
                'James','Jenna','Karl',
                'James','Jenna','Karl',
                'James','Jenna','Karl'
            ],
            key: ['James','Jenna','Karl'],
            keyPosition: 'margin',
            hmargin: 10,
            textSize: 16
        }
    }).wave();
    
    new RGraph.Drawing.YAxis({
        id: 'cvs',
        x: bar.marginLeft,
        options: {
            marginTop: 35,
            yaxisScaleMax: bar.scale2.max * 2,
            yaxisScaleDecimals: 1,
            textColor: 'blue',
            textSize: 16,
            colors: ['blue']
        }
    }).draw();

    new RGraph.Drawing.YAxis({
        id: 'cvs',
        x: bar.marginLeft - 70,
        options: {
            marginTop: 35,
            yaxisScaleMax: bar.scale2.max * 5,
            yaxisScaleDecimals: 1,
            textColor: 'red',
            textSize: 16,
            colors: ['red']
        }
    }).draw();
    
    new RGraph.Drawing.YAxis({
        id: 'cvs',
        x: bar.marginLeft - 140,
        options: {
            marginTop: 35,
            yaxisScaleMax: bar.scale2.max,
            yaxisScaleDecimals: 1,
            tooltips: ['Rainfall measured by the MET office'],
            colors: ['green'],
            textSize: 16
        }
    }).draw();
</script>

Properties

Color properties

PropertyDescriptionDefault
colorsAn array of colors. Even though it's an array only the first color is used.['black']

X axis properties

PropertyDescriptionDefault
xaxisPositionThis can facilitate when you have an X axis in the center (eg the Bar chart).bottom

Y axis properties

PropertyDescriptionDefault
yaxisThis option can be specified if you don't want an axis drawn (the labels are still drawn).false
yaxisTickmarksCountThe number of tickmarks shown on the axis. You may need to +/- 1 to get alignment with grids.null
yaxisTickmarksAlignWhether the tickmarks are aligned to the left or to the right of the axis.left
yaxisTickmarksLastTopThis option can be used to prevent the top end tickmark from being drawn.false
yaxisTickmarksLastBottomThis option can be used to prevent the bottom end tickmark from being drawn.false
yaxisLabelsCountThis determines how many labels are shown by default.5
yaxisLabelsSpecificInstead of having a scale you can instead have specific labels (eg low/medium/high).null
yaxisLabelsFontThe font used to render the Y axis labels.null
yaxisLabelsSizeThe size of the labels.null
yaxisLabelsColorThe color of the labels.null
yaxisLabelsBoldWhether the Y axis labels are bold or not.null
yaxisLabelsItalicWhether the labels are italic or not.null
yaxisScaleFormatterA function used that handles the formatting of numbers. It should return the formatted number.null
yaxisScaleDecimalsThe number of decimals shown.0
yaxisScaleInvertWhether the scale is inverted (ie minimum value at the top).false
yaxisScaleZerostartThis determines whether zero is shown.true
yaxisScaleVisibleThis determines whether the scale is drawn. This value is not checked if you choose to use labels instead.true
yaxisScaleUnitsPreThe units for the scale. This is prepended to the number.An empty string
yaxisScaleUnitsPostThe units for the scale. This is appended to the number.An empty string
yaxisScalePointThe character used as a decimal point..
yaxisScaleThousandThe character used as the thousand separator.,
yaxisScaleMaxThe maximum value of the scale.null
yaxisScaleMinThe minimum value of the scale.0
yaxisTitleThe title for the axis.An empty string
yaxisTitleFontThe font used for the title.null
yaxisTitleSizeThe size of the title.null
yaxisTitleColorThe color of the title.null
yaxisTitleBoldWhether the title is bold or not.null
yaxisTitleItalicWhether the title is italic or not.null

Margin properties

PropertyDescriptionDefault
marginTopThe top margin of the axis. This can be the same or different to the chart.25
marginBottomThe bottom margin of the axis. This can be the same or different to the chart.25

Other label properties

PropertyDescriptionDefault
textColorThe color of the text labels.black
textFontThe font used to render the text.Arial, Verdana, san-serif
textSizeThe size that the text is rendered in.12
textBoldWhether the text is bold or not.false
textItalicWhether the text is italic or not.false

Interactive features properties

PropertyDescriptionDefault
tooltipsThis can be an array of tooltips (only the first element is used) that are shown when the axis is clicked on.null
tooltipsEventThis is the event that triggers the tooltips. It can be either onclick or onmousemove.onclick
tooltipsEffectThe effect used for showing tooltips. Can be either fade or none.fade
tooltipsCssClassThis is the name of the CSS class the chart uses.RGraph_tooltip
tooltipsOverrideIf you wish to handle showing tooltips yourself, this should be a function object which does just that. There's more information on the tooltips documentation page.null
tooltipsNohideonclearNot an option that you'll need particularly often, if at all. Setting this to true means that when you call the RGraph.clear API function the tooltip DOES NOT get hidden.false

Event properties

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

Miscellaneous properties

PropertyDescriptionDefault
linewidthThe linewidth used to draw the axis.1
highlightStyleBy default this is null but you can set it to a function if you wish so that function is called to do the chart highlighting. It's passed the shape object as an argument.null