2015-04-03 189 views
0

我正在使用amCharts的堆積柱狀圖。它會爲類別選擇默認顏色。如何在amCharts堆積柱狀圖中指定堆棧類別的顏色?

我可以更改堆疊的顏色嗎?我想自己指定顏色。我會怎麼做?

http://jsfiddle.net/jn2695pc/

var chart = AmCharts.makeChart("chartdiv", { 
    "type": "serial", 
    "theme": "none", 
    "legend": { 
     "horizontalGap": 10, 
     "maxColumns": 1, 
     "position": "right", 
     "useGraphSettings": true, 
     "markerSize": 10 
    }, 
    "dataProvider": [{ 
     "year": 2003, 
     "europe": 2.5, 
     "namerica": 2.5, 
     "asia": 2.1, 
     "lamerica": 0.3, 
     "meast": 0.2, 
     "africa": 0.1 
    }, { 
     "year": 2004, 
     "europe": 2.6, 
     "namerica": 2.7, 
     "asia": 2.2, 
     "lamerica": 0.3, 
     "meast": 0.3, 
     "africa": 0.1 
    }, { 
     "year": 2005, 
     "europe": 2.8, 
     "namerica": 2.9, 
     "asia": 2.4, 
     "lamerica": 0.3, 
     "meast": 0.3, 
     "africa": 0.1 
    }], 
    "valueAxes": [{ 
     "stackType": "regular", 
     "axisAlpha": 0.3, 
     "gridAlpha": 0 
    }], 
    "graphs": [{ 
     "balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>", 
     "fillAlphas": 0.8, 
     "labelText": "[[value]]", 
     "lineAlpha": 0.3, 
     "title": "Europe", 
     "type": "column", 
     "color": "#000000", 
     "valueField": "europe" 
    }, { 
     "balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>", 
     "fillAlphas": 0.8, 
     "labelText": "[[value]]", 
     "lineAlpha": 0.3, 
     "title": "North America", 
     "type": "column", 
     "color": "#000000", 
     "valueField": "namerica" 
    }, { 
     "balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>", 
     "fillAlphas": 0.8, 
     "labelText": "[[value]]", 
     "lineAlpha": 0.3, 
     "title": "Asia-Pacific", 
     "type": "column", 
     "color": "#000000", 
     "valueField": "asia" 
    }, { 
     "balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>", 
     "fillAlphas": 0.8, 
     "labelText": "[[value]]", 
     "lineAlpha": 0.3, 
     "title": "Latin America", 
     "type": "column", 
     "color": "#000000", 
     "valueField": "lamerica" 
    }, { 
     "balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>", 
     "fillAlphas": 0.8, 
     "labelText": "[[value]]", 
     "lineAlpha": 0.3, 
     "title": "Middle-East", 
     "type": "column", 
     "color": "#000000", 
     "valueField": "meast" 
    }, { 
     "balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>", 
     "fillAlphas": 0.8, 
     "labelText": "[[value]]", 
     "lineAlpha": 0.3, 
     "title": "Africa", 
     "type": "column", 
     "color": "#000000", 
     "valueField": "africa" 
    }], 
    "categoryField": "year", 
    "categoryAxis": { 
     "gridPosition": "start", 
     "axisAlpha": 0, 
     "gridAlpha": 0, 
     "position": "left" 
    }, 
    "exportConfig":{ 
     "menuTop":"20px", 
     "menuRight":"20px", 
     "menuItems": [{ 
     "icon": '/lib/3/images/export.png', 
     "format": 'png' 
     }] 
    } 
}); 

回答

1

只需添加在 「fillColors」: 「#FFFFFF」, 您的每一個 「圖」 作者:[..]

這將填充白色: 即。

"graphs": [{ 
    "balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>", 
    "fillAlphas": 0.8, 
    "labelText": "[[value]]", 
    "lineAlpha": 0.3, 
    "title": "Europe", 
    "type": "column", 
    "color": "#000000", 
    "fillColors": "#ffffff", 
    "valueField": "europe" 
},