JpGraph饼图切片颜色不起作用

Sai*_*que 5 jpgraph pie-chart

我在php中使用了JpGraph.一切都好但切片($ p1-> SetSliceColors($ color);)颜色不起作用.它一直是默认颜色.这是我用过的代码.请帮我 :

    $data    = array('40','50', '10');
    $Legends = array('Loss','Win',  'Draw');
    $labels  = array("Loss\n(%.1f%%)","Win\n(%.1f%%)","Draw\n(%.1f%%)");
    $color   = array('red','red','red');
    $graph   = new PieGraph(550,350);
    $graph->SetShadow();

    $p1 = new PiePlot3D($data);
    $p1->ExplodeSlice(1);
    $p1->SetCenter(0.55);
    $p1->SetLegends($Legends);
    $graph->legend->Pos(0.5,0.1);


    $p1->SetTheme("earth");
    $p1->SetSliceColors($color);

    // Setup the labels to be displayed
    $p1->SetLabels($labels);
    $p1->SetLabelPos(1);
    $p1->SetLabelType(PIE_VALUE_PER);
    $p1->value->Show();
    $p1->value->SetFont(FF_FONT1,FS_NORMAL,9);
    $p1->value->SetColor('navy');

    $graph->Add($p1);
    $graph->Stroke();
Run Code Online (Sandbox Code Playgroud)

小智 11

我有同样的问题.在设置颜色之前调用Add方法:

$p1 = new PiePlot3D($data);
$graph->Add($p1);
Run Code Online (Sandbox Code Playgroud)

更改线条/条形图的显示设置


小智 5

尝试

 $graph   = new PieGraph(550,350);
 $graph->ClearTheme();
Run Code Online (Sandbox Code Playgroud)

忽略

 $p1->SetTheme("earth");
Run Code Online (Sandbox Code Playgroud)

SetSliceColors为我工作.