Amcharts: Column chart color

Delfalso picture Delfalso · May 20, 2014 · Viewed 22.7k times · Source

I followed this code http://jsfiddle.net/amcharts/w8Bcy/ to create my own column chart. I succed but now i want to improve that charts with other options.

Actual chart def is :

var chart = AmCharts.makeChart("chartdiv", {
"type": "serial",
    "theme": "none",
    "dataProvider": chartData,
    "valueAxes": [{
    "gridColor": "#FFFFFF",
        "gridAlpha": 0.2,
        "dashLength": 0
}],
    "gridAboveGraphs": true,
    "startDuration": 1,
    "graphs": [{
    "balloonText": "[[category]]: <b>[[value]]</b>",
        "fillAlphas": 0.8,
        "lineAlpha": 0.2,
        "type": "column",
        "valueField": "visits"
}],
    "chartCursor": {
    "categoryBalloonEnabled": false,
        "cursorAlpha": 0,
        "zoomable": false
},
    "categoryField": "country",
    "categoryAxis": {
    "gridPosition": "start",
        "gridAlpha": 0
},
    "exportConfig": {
    "menuTop": 0,
        "menuItems": [{
        "icon": '/lib/3/images/export.png',
            "format": 'png'
    }]
}
});

I have multiple column with some values, and i want the column to have a color based on their values. How i can change column color with value?

Example: Under x, column will be red . Above x, column will be green .

I also want to trace a line with the reference value.

Thanks.

Answer

ddw147 picture ddw147 · May 26, 2014
graph.colorField = "color"

and in data add field

       "color" : "your color hex code "

its done check at http://jsfiddle.net/w8Bcy/68/ i have color all of them red , you can add color of your choice when your generating your data / json