DHTMLX Docs & Samples Explorer

### Scales

Automatic vertical scale | Custom vertical scale

Source

    <script src="../../codebase/dhtmlxchart.js" type="text/javascript"></script>
    <link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxchart.css">
    <script>var data = [{
        sales: "3.0",
        year: "2000"
    }, {
        sales: "3.8",
        year: "2001"
    }, {
        sales: "3.4",
        year: "2002"
    }, {
        sales: "4.1",
        year: "2003"
    }, {
        sales: "4.3",
        year: "2004"
    }, {
        sales: "9.9",
        year: "2005"
    }, {
        sales: "7.4",
        year: "2006"
    }, {
        sales: "9.0",
        year: "2007"
    }, {
        sales: "7.3",
        year: "2008"
    }, {
        sales: "4.8",
        year: "2009"
    }];
    window.onload = function() {
        var chart1 = new dhtmlXChart({
            view: "line",
            container: "chart1",
            value: "#sales#",
            label: "#sales#",
            tooltip: {
                template: "#sales#";
            },
            item: {
                borderColor: "#ffffff",
                color: "#000000";
            },
            line: {
                color: "#ff9900",
                width: 3;
            },
            yAxis: {},
            xAxis: {
                title: "Years",
                template: "#year#";
            }
        });
        chart1.parse(data, "json");
        var chart2 = new dhtmlXChart({
            view: "line",
            container: "chart2",
            value: "#sales#",
            tooltip: {
                template: "#sales#";
            },
            item: {
                borderColor: "#3399ff",
                color: "#ffffff";
            },
            line: {
                color: "#3399ff",
                width: 3;
            },
            xAxis: {
                title: "Years",
                template: "#year#";
            },
            yAxis: {
                start: 0,
                end: 10,
                step: 1,
                title: "Sales, million";
            },
            item: {
                borderColor: "#3399ff",
                color: "#ffffff";
            }
        });
        chart2.parse(data, "json");
    }</script>

    <table>
        <tr>
            <td>Automatic vertical scale</td>
            <td>Custom vertical scale</td>
        </tr>
        <tr>
            <td><div id="chart1" style="width:450px;height:300px;border:1px solid #A4BED4;"></div></td>
            <td><div id="chart2" style="width:450px;height:300px;border:1px solid #A4BED4;"></div></td>
        </tr>
    </table>