如何更改 JpChart 的 3D 饼图主题
How to Change Theme On 3D Pie for JpChart
我无法在 3D 饼图上更改主题或切片颜色。我的代码是:
$graph = new PieGraph(350,250);
$graph->SetShadow();
$graph->title->SetFont(FF_VERDANA,FS_BOLD,18);
$graph->title->SetColor("darkblue");
$graph->legend->Pos(0.1,0.9);
// Create 3D pie plot
$p1 = new PiePlot3d($data);
$p1->SetLegends($legends);
$p1->SetTheme("earth");
$p1->SetCenter(0.4);
$p1->SetSize(100);
$p1->SetSliceColors(array("red","blue","yellow","orange"));
$p1->SetAngle(45);
$p1->value->SetFont(FF_ARIAL,FS_BOLD,8);
$p1->value->SetColor("navy");
$graph->Add($p1);
无论我做什么,颜色都不会改变。我错过了什么吗?
在更改主题和颜色之前将绘图添加到图表中。如果你仔细想想,这是非常有道理的。您必须先创建 (define/add) 才能修改它。
下面显示的更改应该有效:
// Create 3D pie plot
$p1 = new PiePlot3d($data);
$graph->Add($p1); // moved adding the plot to the graph before changing other things
$p1->SetLegends($legends);
$p1->SetTheme("earth");
$p1->SetCenter(0.4);
$p1->SetSize(100);
$p1->SetSliceColors(array("red","blue","yellow","orange"));
$p1->SetAngle(45);
$p1->value->SetFont(FF_ARIAL,FS_BOLD,8);
$p1->value->SetColor("navy");
我无法在 3D 饼图上更改主题或切片颜色。我的代码是:
$graph = new PieGraph(350,250);
$graph->SetShadow();
$graph->title->SetFont(FF_VERDANA,FS_BOLD,18);
$graph->title->SetColor("darkblue");
$graph->legend->Pos(0.1,0.9);
// Create 3D pie plot
$p1 = new PiePlot3d($data);
$p1->SetLegends($legends);
$p1->SetTheme("earth");
$p1->SetCenter(0.4);
$p1->SetSize(100);
$p1->SetSliceColors(array("red","blue","yellow","orange"));
$p1->SetAngle(45);
$p1->value->SetFont(FF_ARIAL,FS_BOLD,8);
$p1->value->SetColor("navy");
$graph->Add($p1);
无论我做什么,颜色都不会改变。我错过了什么吗?
在更改主题和颜色之前将绘图添加到图表中。如果你仔细想想,这是非常有道理的。您必须先创建 (define/add) 才能修改它。
下面显示的更改应该有效:
// Create 3D pie plot
$p1 = new PiePlot3d($data);
$graph->Add($p1); // moved adding the plot to the graph before changing other things
$p1->SetLegends($legends);
$p1->SetTheme("earth");
$p1->SetCenter(0.4);
$p1->SetSize(100);
$p1->SetSliceColors(array("red","blue","yellow","orange"));
$p1->SetAngle(45);
$p1->value->SetFont(FF_ARIAL,FS_BOLD,8);
$p1->value->SetColor("navy");