Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amcharts: Column chart color

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.

like image 827
Delfalso Avatar asked Jan 11 '23 13:01

Delfalso


1 Answers

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

like image 103
Dhiraj Wakchaure Avatar answered Jan 21 '23 13:01

Dhiraj Wakchaure