# A combined Bar and Line chart

This goes in the documents header:

    <script src="RGraph.common.core.js"></script>
    <script src="RGraph.bar.js"></script>
    <script src="RGraph.line.js"></script>

Put this where you want the chart to show up:

    <canvas id="cvs" width="900" height="250" style="background-color: #555; border: 5px solid black; border-radius: 7px; box-shadow: 2px 2px 3px gray">
        [No canvas support]
    </canvas>

This is the code that generates the chart:

    <script>
        window.onload = function ()
        {
            var bar = new RGraph.Bar({
                id: 'cvs',
                data: [81,90,75,85,90,78],
                options: {
                    ymax: 100,
                    backgroundGridVlines: false,
                    backgroundGridBorder: false,
                    backgroundGridColor: '#999',
                    numyticks: 12,
                    labels: ['1','2','3','4','5','6'],
                    hmargin: 30,
                    gutterTop: 10,
                    gutterLeft: 45,
                    gutterRight: 45,
                    colors: ['#A18AC5'],
                    textColor: '#ccc',
                    axisColor: '#999',
                    numxticks: 0,
                    shadowColor: 'black',
                    shadowOffsetx: 0,
                    shadowOffsety: 0,
                    shadowBlur: 15,
                    scaleZerostart: true,
                    strokestyle: 'rgba(0,0,0,0)',
                    textAccessible: true
                }
            })

            var line = new RGraph.Line({
                id: 'cvs',
                data: [150,73,160,350,490,250],
                options: {
                    ymax: 600,
                    noaxes: true,
                    backgroundGrid: false,
                    linewidth: 7,
                    colors: ['#d00'],
                    yaxispos: 'right',
                    axisColor: '#999',
                    textColor: '#ccc',
                    gutterLeft: 45,
                    gutterRight: 45,
                    tickmarks: null,
                    textAccessible: true
                }
            })

            var combo = new RGraph.CombinedChart([bar, line])
                .draw();

            // Because the combo class turns the line chart labels off,
            // turn them back on
            line.set({
                ylabels: true,
                scaleZerostart: true
            });
            RGraph.redraw();
        };
    </script>

« Back