DHTMLX Docs & Samples Explorer

Colors: custom colors

Colors can be defined with template. In this sample colors and defined in data by "color" field.

Source
<script src="../../codebase/dhtmlxchart.js" type="text/javascript"></script>
<link rel="STYLESHEET" type="text/css" href="../../codebase/dhtmlxchart.css">
<style>
    .dhx_chart_title{
        padding-left:3px
    }
</style>
<script>
var data = [{
    sales: "2.9",
    year: "2000",
    color: "#0000FF"
}, {
    sales: "3.5",
    year: "2001",
    color: "#00FF00"
}, {
    sales: "3.1",
    year: "2002",
    color: "#00FFFF"
}, {
    sales: "4.2",
    year: "2003",
    color: "#FF0000"
}, {
    sales: "4.5",
    year: "2004",
    color: "#FF00FF"
}, {
    sales: "9.6",
    year: "2005",
    color: "#FFFF00"
}, {
    sales: "7.4",
    year: "2006",
    color: "#880088"
}, {
    sales: "9.0",
    year: "2007",
    color: "#008800"
}, {
    sales: "7.3",
    year: "2008",
    color: "#880000"
}, {
    sales: "4.8",
    year: "2009",
    color: "#000088"
}];
window.onload = function() {
    var barChart = new dhtmlXChart({
        view: "bar",
        container: "chart_container",
        value: "#sales#",
        label: "#year#",
        color: "#color#",
        padding: {
            bottom: 0,
            right: 0,
            left: 0;
        },
        width: 30;
    });
    barChart.parse(data, "json");
    var barChart2 = new dhtmlXChart({
        view: "pie",
        container: "chart_container2",
        value: "#sales#",
        details: "#year#",
        color: "#color#";
    });
    barChart2.parse(data, "json");
}
</script> <div id="chart_container" style="width:450px;height:300px;border:1px solid #A4BED4;float:left;margin-right:20px"></div> <div id="chart_container2" style="width:450px;height:300px;border:1px solid #A4BED4;"></div>