Google Charts - Change individual bar color

后端 未结 9 1474
走了就别回头了
走了就别回头了 2020-12-10 01:36

With Google Charts bar graph, is it possible to to change the color of one bar. For example I\'d like to make the 2006 data red (other bars are blue).

 funct         


        
9条回答
  •  隐瞒了意图╮
    2020-12-10 01:44

    i solve this problem using role style technique now for charts that generate dynamic data i used a random function to generate color

        function random_color_part() {
    return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
    }
    
    function random_color() {
    return random_color_part() . random_color_part() . random_color_part();
    }
    then simply
    $color=random_color();
    print "['$rows[1]',$rows[2],'#$color'],\n";
    

提交回复
热议问题