- Home ›
- JpGraphを使ったグラフの描画 ›
- 円グラフ(PiePlot) ›
- HERE
中央部分の色を指定する
広告
円グラフの中央の円部分の色を指定することができます。指定するにはPiePlotCクラスで用意されている「SetMidColor」メソッドを使います。
SetMidColor function SetMidColor($aColor)
Specify fill color for center circle Parameter: $aColor Color
引数に中央の円の色を指定します。色の指定方法はキーワードでの指定やRGB形式、16進数を使った指定方法などがあります。詳しくは『JpGraphにおける色の指定方法』を参照して下さい。
実際には次のように記述します。
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_pie.php");
$data = array(32, 21, 24, 35, 18);
$pieplotc = new PiePlotC($data);
$pieplotc->SetMidColor("yellow");
$graph = new PieGraph(250, 200);
$graph->Add($pieplotc);
サンプル
それでは実際に試して見ます。
<?php
include ("jpgraph/jpgraph.php");
include ("jpgraph/jpgraph_pie.php");
$graph = new PieGraph(250, 200, "auto");
$graph->SetFrame(true);
$data = array(45, 23, 18, 32);
$pieplotc = new PiePlotC($data);
$pieplotc->SetMidColor("yellow");
$graph->Add($pieplotc);
$graph->Stroke();
?>
上記のPHPファイルをブラウザで開いてみます。ブラウザには次のように表示されます。
( Written by Tatsuo Ikura )
PHPBook