0

I use this very Highchart Pie in my application. How to set custom color for each slices based on the output?

I use this script before the highchart script to change the color but it seems to have no effect.

Highcharts.theme = {
  colors: ['#000000', 
           '#FFFFFF', 
           '#FF00FF', 
           '#DDDF00', 
           '#24CBE5', 
           '#64E572', 
           '#FF9655', 
           '#FFF263', 
           '#6AF9C4'],

};
// Apply the theme
Highcharts.setOptions(Highcharts.theme);

This is the highchart:

Highcharts.chart('container', {

title: {
    text: 'GRAFIK PENGADAAN SCG'
},
series: [{
    name                : 'Jumlah',
    colorByPoint        : true,
    type                : 'pie',
    allowPointSelect    : true,
    keys                : ['name', 'y', 'selected', 'sliced'],
    data                : [
                            <?php

                                $arr_act = "";
                                foreach($graph_act as $res_act){

                                    $arr_act .= "['".$res_act['ACT']."',".$res_act['JUMLAH'].",false],";

                                }
                                echo rtrim($arr_act, ',');
                            ?> 

                          ]
    }]
});
Dmitry
  • 6,716
  • 14
  • 37
  • 39
ashura91
  • 441
  • 4
  • 17
  • Did you try any of the things returned when searching for your title? Such as https://stackoverflow.com/questions/30100211/how-can-i-put-custom-color-in-high-charts-pie-data-slice-and-want-to-change-sl or this one: https://stackoverflow.com/a/40803914/295783 – mplungjan Nov 20 '17 at 07:20
  • @mplungjan yes. but I think I fail to implement it in my app. No exact example match the highchart script I use – ashura91 Nov 20 '17 at 07:27
  • @ashura91 check this http://jsfiddle.net/4n438g4z/ – Deep 3015 Nov 20 '17 at 07:47
  • @Deep3015 something weird happen. when I add color all `#FF0000` (11 slices), only a slice has red color. – ashura91 Nov 20 '17 at 07:59
  • @ashura91 still I am not getting can you reproduce example and add fiddle – Deep 3015 Nov 20 '17 at 08:07
  • @Deep3015 please check this.https://jsfiddle.net/ts3f5o56/. you can edit it if you want – ashura91 Nov 20 '17 at 08:15
  • 1
    @ashura91 Check commented portion in html and css section of code. https://jsfiddle.net/ts3f5o56/1/ – Deep 3015 Nov 20 '17 at 08:42

0 Answers0