The drawing API X axis object

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

[No canvas support]

The X axis object allows you to have extra X 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>
   var bar = new RGraph.Bar({
        id: 'cvs',
        data: [4,8,6,5,6,9,9,4],
        options: {
            axes: false,
            textSize: 14,
            marginBottom: 45,
            colors: ['gradient(white:red)'],
            shadow: false,
            backgroundGridVlines: false,
            backgroundGridBorder: false
        }
    }).draw();
    
    var xaxis = new RGraph.Drawing.XAxis({
        id: 'cvs',
        y: bar.canvas.height - bar.marginBottom,
        options: {
            tooltips: ['The X axis represents each<br />person teaching at the college.'],
            xaxisLabels: ['Rich','Alex','Johnny','Kev','Pete','Luis','John','Barry'],
            colors: ['#666'],
            xaxisTitle: 'The X axis',
            textSize: 14
        }
    }).draw();
</script>

Properties

Color properties

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

Title properties

PropertyDescriptionDefault
titleThe title for the axis.An empty string
titleColorThe color of the title. If not specified then it's the same as the colors option.null

Margin properties

PropertyDescriptionDefault
marginLeftThe left margin of the axis. This can be the same or different to the chart.25
marginRightThe right margin of the axis. This can be the same or different to the chart.25
hmarginThe (inner) horizontal margin of the axis. Useful for matching up labels/points of the Line chart.0

X axis properties

PropertyDescriptionDefault
xaxisThis option can be specified if you don't want an axis drawn (the labels are still drawn).true
xaxisLabelsInstead of a scale you can use this to specify labels for the X axis.null
xaxisLabelsPositionThis cand be edge or section and detemines how the labels are aligned. For an illustration compare the labels of the Bar chart vs the labels of the Line chart.section
xaxisLabelsCountWhen showing a scale this determines how many labels are shown.5
xaxisTickmarksCountThe number of tickmarks shown on the axis. You may need to +/- 1 to get alignment with grids.null
xaxisTickmarksAlignThe alignment of the tickmarks and labels. This can be top or bottom.bottom
xaxisTickmarksEndLeftThis option can be used to prevent the left end tickmark from being drawn.false
xaxisTickmarksEndRightThis option can be used to prevent the right end tickmark from being drawn.false
xaxisPositionUusually bottom, though you can set this to center and the tickmarks will start above the axis and end below the axis.bottom
xaxisScaleVisibleThis determines whether the scale is displayed.true
xaxisScaleFormatterThis should be a function that returns the correctly formatted number. For example:
function myFormatter (obj, number)
{
    // Return the formatted number
    return number;
}

xaxis.set('scale.formatter', myFormatter)
null
xaxisScaleDecimalsThe number of decimals shown.0
xaxisScaleInvertWhether the scale is inverted (ie minimum value at the top)false
xaxisScaleZerostartThis determines whether zero is shown.true
xaxisScaleUnitsPreThe units for the scale. This is prepended to the number.An empty string
xaxisScaleUnitsPostThe units for the scale. This is appended to the number.An empty string
xaxisScaleMaxThe maximum value of the scale.null
xaxisScaleMinThe minimum value of the scale.0

Y axis properties

PropertyDescriptionDefault
yaxisPositionThis can facilitate when you have a Y axis in the center (eg the Horizontal Bar chart).left

Other label properties

PropertyDescriptionDefault
textColorThe color of the text. If not specified then it's the same as the colors option.null
textFontThe font used when rendering the text.Arial
textSizeThe size used when rendering text10

Interactive features properties

PropertyDescriptionDefault
tooltipsThis can be 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 pagenull
tooltipsNohideonclearNot an option that you'll need particularly often if at all. Setting this to true means that when you call the RGraph.clear() API function tooltip DO NOT get hidden.false

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

Miscellaneous properties

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