DHTMLX Docs & Samples Explorer

Scales

Custom vertical scale and origin Automatic vertical scale
Source
<script src="../../codebase/dhtmlxchart.js" type="text/javascript"></script>
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxchart.css">
 
 
<table>
    <tr>
        <td>Custom vertical scale and origin</td>
        <td>Automatic 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>
 
<script>
var data = [{
    sales: "-2.0",
    year: "2000"
}, {
    sales: "-0.4",
    year: "2001"
}, {
    sales: "1.1",
    year: "2002"
}, {
    sales: "3.3",
    year: "2003"
}, {
    sales: "1.2",
    year: "2004"
}, {
    sales: "1.8",
    year: "2005"
}, {
    sales: "4.1",
    year: "2006"
}, {
    sales: "5.5",
    year: "2007"
}, {
    sales: "3.5",
    year: "2008"
}, {
    sales: "1.8",
    year: "2009"
}];
 
var barChart1 = new dhtmlXChart({
    view: "bar",
    container: "chart1",
    value: "#sales#",
    width: 30,
    tooltip: {
        template: "#sales#";
    },
    xAxis: {
        template: "#year#",
        title: "Year";
    },
    yAxis: {
        start: -3,
        end: 7,
        step: 1,
        title: "Profit";
    },
    origin: 0,
    gradient: true,
    border: false;
});
barChart1.parse(data, "json");
 
var barChart2 = new dhtmlXChart({
    view: "bar",
    container: "chart2",
    value: "#sales#",
    gradient: true,
    border: false,
    width: 30,
    tooltip: {
        template: "#sales#";
    },
    xAxis: {
        template: "#year#",
        title: "Year";
    },
    yAxis: {
        title: "Profit";
    }
});
barChart2.parse(data, "json");
</script>