I have 3 dataseries which comes from an array.
For each dataseries, I have to use the same color.
I used the property of
colors: ['#0000FF', '#0066FF', '#00CCFF']
Result - It is combining these colors with different dataseries
For 1st dataseries, I need '#0000FF'
For 2nd dataseries, I need '#0066FF'
For 3rd dataseries, I need '#00CCFF'
Here's my code below
for($i=1;$i<=$getCurrentMonth;$i++){
$month = date("M", mktime(0, 0, 0, $i, 10));
if(isset($elementDetails[$i])){
foreach($elementDetails[$i] as $value1){
$dataDetails = '';
for($j=1;$j<$i;$j++){
$monthname = date("M", mktime(0, 0, 0, $j, 10));
$dataDetails .= "{name:'".$monthname."',y: 0},";
}
foreach($value1 as $key => $value){
$seriesDetails .= "{ name: '".$key."',data: [".$dataDetails."{name:'".$month."',y: ".$value."}],stack: '".$key."'},";
//echo $key;
}
}
}
}
For each dataseries, I need a specific color.
Highcharts.chart('container', {
colors: ['#0000FF', '#0066FF', '#00CCFF'],
xAxis: {
min: 0,
max: <?php echo $getCurrentMonth-1;?>,
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: '',
}
},
chart: {
type: 'column'
},
tooltip: {
shared: true
},
plotOptions: {
series: {
stacking: 'normal',
pointPadding: 0,
groupPadding: 0.1,
}
},
series: $seriesDetails;
});
You can set color for each series by color
property as below:
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 95.6, 54.4],
color:'#0000FF'
},
{
data: [194.1, 95.6, 54.4,129.2, 144.0, 176.0,29.9],
color:'#0066FF'
}]
Working jsFiddle here: http://jsfiddle.net/o2j1yd7z/2/