简体   繁体   中英

one series, multiple colors, google charts combo chart

I have the following code with only one series. I cannot add another series due with the data I am working with - the challenge I am presented with is to style the bars on the bar chart with different colors. Any suggestions?

var options = {
title:selVal + ': Electricity Consumption Yearly % Change',
legend:{alignment:'center', position:'bottom'},
vAxis:{title:'Yearly % Change', format:'#,###%'},
seriesType: "bars",
width:600, 
height:300
};

You can give multiple colors by giving an array of colors in the option

var options = {
title:selVal + ': Electricity Consumption Yearly % Change',
legend:{alignment:'center', position:'bottom'},
vAxis:{title:'Yearly % Change', format:'#,###%'},
seriesType: "bars",
width:600, 
height:300,
colors: ["red","blue","green"]
};
var options = {
          legend: 'none',
          series: {
            0: { color: '#e2431e' },
            1: { color: '#e7711b' },
            2: { color: '#f1ca3a' },
            3: { color: '#6f9654' },
            4: { color: '#1c91c0' },
            5: { color: '#43459d' },
          }
        };

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM