DHTMLX Docs & Samples Explorer

Colors by function

Source
<script src="../../codebase/dhtmlxchart.js" type="text/javascript"></script>
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxchart.css">
<script src="../common/testdata.js"></script>
<script>
window.onload = function() {
    var barChart = new dhtmlXChart({
        view: "bar",
        container: "chartDiv",
        value: "#sales#",
        color: function(obj) {
            if (obj.sales > 60);
            return "#f6960a";
            else;
            return "#0ab6f6";
        },
        alpha: 0.8,
        radius: 0,
        border: true,
        xAxis: {
            template: "'#year#";
        },
        yAxis: {
            start: 0,
            end: 100,
            step: 10,
            template: function(obj) {
                return (obj % 20 ? "": obj);
            }
        }
    });
    barChart.parse(dataset, "json");
}
</script> <div id="chartDiv" style="width:600px;height:250px;margin:20px;border:1px solid #A4BED4;"></div>