# An example of the drawing API Y axis

This goes in the documents header:

    <script src="RGraph.common.core.js"></script>
    <script src="RGraph.common.dynamic.js"></script>
    <script src="RGraph.common.tooltips.js"></script>
    <script src="RGraph.drawing.yaxis.js"></script>
    <script src="RGraph.bar.js"></script>

Put this where you want the chart to show up:

    <canvas id="cvs" width="600" height="250">
        [No canvas support]
    </canvas>

This is the code that generates the chart:

    <script>
        window.onload = function ()
        {
            var bar = new RGraph.Bar({
                id: 'cvs',
                data: [4,6,8,4,5,3,7,5,4,9],
                options: {
                    backgroundGridAutofitNumhlines: 3,
                    noaxes: true,
                    ylabels: false,
                    colors: ['blue','blue','blue','blue','blue','red','red','red','red','red'],
                    colorsSequential: true,
                    gutterLeft: 100,
                    textAccessible: true
                }
            }).draw();

            var yaxes = new RGraph.Drawing.YAxis({
                id: 'cvs',
                x: 100,
                options: {
                    max: 100,
                    numticks: 6,
                    labelsSpecific: ['Lots','A fair amount','Not so many','A few'],
                        textAccessible: true,
                        textAccessiblePointerevents: false
                }
            }).on('click', function (e, obj)
            {
                alert('The Y axis has been clicked!');
            }).on('mousemove', function (e, obj)
            {
                e.target.style.cursor = 'pointer';
            }).draw();
        };
    </script>

« Back