Commit 5e975caf authored by 君塚 悠's avatar 君塚 悠

プログラム作成(graph.php,graph_gen.php:グラフ生成)

parent a9330410
<html>
<head>
<title>棒グラフの動的生成</title>
</head>
<body>
<h1 style = "background:#cccccc">書籍売り上げ傾向 (2005年第一四半期)</h1>
<img src = "graph_gen.php" width = "450" height = "250" />
</body>
</html>
<?php
//JpGraphによる棒グラフの生成
require_once ("jpgraph/jpgraph.php");
require_once ("jpgraph/jpgraph_bar.php");
//グラフの基本設定
$objGrh = new Graph(450, 250, "auto");
$objGrh -> SetScale("textlin");
$objGrh -> title -> Set("Books Trend");
$objGrh -> xaxis -> title -> Set("2005.4Q");
$objGrh -> yaxis -> title-> Set("Quantity");
//グラフのデータ設定
$data = array(array(350, 200, 280), array(295, 150, 290), array(295, 150, 290), array(315, 180, 220));
$objPlot[] = new BarPlot($data[0]);
$objPlot[] = new BarPlot($data[1]);
$objPlot[] = new BarPlot($data[2]);
$objPlot[0] -> SetLegend('PHP');
$objPlot[1] -> SetLegend('ASP');
$objPlot[2] -> SetLegend('ASP');
$objPlot[0] -> SetFillcolor('red@0.7');
$objPlot[1] -> SetFillcolor('blue@0.7');
$objPlot[2] -> SetFillcolor('green@0.7');
//グラフの出力
$objGbp = new GroupBarPlot($objPlot);
$objGbp -> SetWidth(0.90);
$obpGrh -> Add($objGbp);
$objGrh -> Stroke();
?>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment