1
0
Fork 0
This commit is contained in:
Chenx221 2024-01-19 16:09:29 +08:00
parent 92f0e435e7
commit e44efa9f50
8 changed files with 165 additions and 3 deletions

6
.idea/encodings.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/12.test5.php" charset="UTF-8" />
</component>
</project>

View File

@ -15,10 +15,10 @@ $graph->Add($barPlot); //将柱状图添加到图像中
$barPlot->value->Show(); //设置显示数字
$barPlot->value->SetFormat('%d'); //设置数字显示格式
$graph->SetMarginColor('lightblue'); //设置图像边距颜色 为浅蓝色
$graph->title->Set(mb_convert_encoding('销量统计', 'gb2312', 'auto')); //设置图像标题
$graph->title->Set('销量统计'); //设置图像标题
$a = mb_convert_encoding(array('1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月',
'11月', '12月'),'gb2312', 'auto'); //设置X轴刻度值
$a = array('1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月',
'11月', '12月'); //设置X轴刻度值
$graph->xaxis->SetTickLabels($a); //设置X轴刻度值
$graph->title->SetFont(FF_SIMSUN); //设置图像标题字体
$graph->xaxis->SetFont(FF_SIMSUN); //设置X轴刻度值字体

32
12.test4.php Normal file
View File

@ -0,0 +1,32 @@
<?php
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
$datay = array(8320, 9360, 14956, 17028, 13060, 15376, 25428, 16216, 28548, 18632, 22724, 28460);
$graph = new Graph(600, 300,'auto');
$graph->img->SetMargin(50,40,30,40);
$graph->img->SetAntiAliasing();
$graph->SetScale('textlin');
$graph->SetShadow();
$graph->title->Set('图书销售折线图');
$graph->title->SetFont(FF_SIMSUN,FS_BOLD);
$graph->SetMarginColor('lightblue');
$graph->yaxis->title->SetFont(FF_SIMSUN,FS_BOLD);
$graph->yaxis->SetPos('min');
$graph->yaxis->hideZeroLabel();
$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#BBCCFF@0.5');
$a = array('1月','2月','3月','4月','5月','6月','7月','8月','9月','10月', '11月','12月');
$graph->xaxis->SetTickLabels($a);
$graph->xaxis->SetFont(FF_SIMSUN);
$graph->yscale->SetGrace(20);
$linePlot = new LinePlot($datay);
$linePlot->mark->SetType(MARK_FILLEDCIRCLE);
$linePlot->mark->SetFillColor('red');
$linePlot->mark->SetWidth(4);
$linePlot->SetColor('blue');
$linePlot->SetCenter();
$graph->Add($linePlot);
$graph->Stroke();

24
12.test5.php Normal file
View File

@ -0,0 +1,24 @@
<?php
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_pie.php';
require_once 'jpgraph/jpgraph_pie3d.php';
$data = array(266036, 295621, 335851, 254256, 254254, 685425);
$data_title = array('IT数码', '家电通讯', '家居日用', '服装鞋帽', '健康美容', '食品烟酒');
$title = '年销售额占比';
$pieGraph = new PieGraph(540, 260, 'auto');
$piePlot3D = new PiePlot3D($data);
$pieGraph->SetShadow();
$pieGraph->title->Set($title);
$pieGraph->title->SetFont(FF_SIMSUN, FS_BOLD);
$pieGraph->legend->SetFont(FF_SIMSUN, FS_BOLD);
$piePlot3D->SetLegends($data_title);
$targ = array("pie3d_csimex1.php?v = 1", "pie3d_csimex1.php?v = 2", "pie3d_csimex1.php?v = 3", "pie3d_csimex1.php?v = 4", "pie3d_csimex1.php?v = 5", "pie3d_csimex1.php?v = 6");
$alts = array("val = %d", "val = %d", "val = %d", "val = %d", "val = %d", "val = %d");
$piePlot3D->SetCSIMTargets($targ, $alts);
$piePlot3D->SetCenter(0.4, 0.5);
$pieGraph->Add($piePlot3D);
$pieGraph->Stroke();

33
12.work1.php Normal file
View File

@ -0,0 +1,33 @@
<?php
require_once 'jpgraph/jpgraph.php'; //引入jpgraph类库
require_once 'jpgraph/jpgraph_bar.php'; //引入柱状图类库
$datay1 = array(58, 85, 65, 39, 120, 91, 152, 49, 97, 130, 67);
$datay2 = array(18, 35, 101, 69, 138, 131, 112, 149, 88, 60, 77);
$graph = new Graph(600, 300, 'auto'); //创建新的Graph对象 600*300像素 自动调整大小
$graph->SetScale('textlin'); //设置刻度样式 为文本型
//$graph->yaxis->scale->SetGrace(20); //设置Y轴刻度值的上下限值 为20
$graph->SetShadow(); //设置阴影
$graph->img->SetMargin(40, 30, 30, 40); //设置图像边距
$barPlot1 = new BarPlot($datay1); //创建BarPlot对象
$barPlot1->SetFillColor('orange'); //设置柱状图填充颜色
$barPlot1->SetShadow();
$barPlot2 = new BarPlot($datay2);
$barPlot2->SetFillColor('yellow'); //设置柱状图填充颜色
$barPlot2->SetShadow();
$groupBarPlot = new GroupBarPlot(array($barPlot1, $barPlot2));
$groupBarPlot->SetWidth(0.6);
$graph->Add($groupBarPlot);
$graph->SetMarginColor('lightblue'); //设置图像边距颜色 为浅蓝色
$graph->title->Set('应用柱形图依次统计2020年液晶电视、电冰箱的月销量'); //设置图像标题
$graph->title->SetFont(FF_SIMSUN); //设置图像标题字体
$a = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); //设置X轴刻度值
$graph->xaxis->SetTickLabels($a); //设置X轴刻度值
$graph->Stroke(); //输出图像

26
12.work2.php Normal file
View File

@ -0,0 +1,26 @@
<?php
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
$datay = array(83,57,93,112,142,112,89,125,69,105,118,75);
$graph = new Graph(600, 300,'auto');
$graph->img->SetMargin(50,40,30,40);
$graph->img->SetAntiAliasing();
$graph->SetScale('textlin');
$graph->SetShadow();
$title = '2020年轿车的月销量统计';
$graph->tabtitle->Set($title);
$graph->tabtitle->SetFont(FF_SIMSUN,FS_BOLD);
$a = array('1月','2月','3月','4月','5月','6月','7月','8月','9月','10月', '11月','12月');
$graph->xaxis->SetTickLabels($a);
$graph->xaxis->SetFont(FF_SIMSUN);
$graph->xgrid->Show();
$linePlot = new LinePlot($datay);
$linePlot->mark->SetType(MARK_IMG,'images/car.gif',0.8);
$linePlot->SetCenter();
$graph->Add($linePlot);
$graph->Stroke();

41
12.work3.php Normal file
View File

@ -0,0 +1,41 @@
<?php
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_pie.php';
require_once 'jpgraph/jpgraph_pie3d.php';
function createPiePlot3D($data, $legends, $centerX, $centerY, $title): PiePlot3D
{
$piePlot3D = new PiePlot3D($data);
$piePlot3D->SetLegends($legends);
$piePlot3D->SetSize(0.13);
$piePlot3D->SetCenter($centerX, $centerY);
$piePlot3D->title->Set($title);
$piePlot3D->title->SetFont(FF_SIMSUN,FS_BOLD);
$piePlot3D->title->SetMargin(10,40,10,40);
return $piePlot3D;
}
$data1 = array(40,21,17,14,23);
$data2 = array(60,54,107,24,83);
$data3 = array(52,151,99,110,223);
$data4 = array(70,181,117,114,33);
$year_data = array("2016年","2017年","2018年","2019年");
$arr = array("大豆","玉米","水稻","小麦","高梁");
$title = '统计2016年、2017年、2018年、2019年农产品的产量比率';
$pieGraph = new PieGraph(600, 350, 'auto');
$pieGraph->SetShadow();
$pieGraph->title->Set($title);
$pieGraph->title->SetFont(FF_SIMSUN, FS_BOLD);
$pieGraph->legend->SetFont(FF_SIMSUN, FS_BOLD);
$piePlot3D1 = createPiePlot3D($data1, $arr, 0.25, 0.25, "2016年");
$piePlot3D2 = createPiePlot3D($data2, $arr, 0.65, 0.25, "2017年");
$piePlot3D3 = createPiePlot3D($data3, $arr, 0.25, 0.65, "2018年");
$piePlot3D4 = createPiePlot3D($data4, $arr, 0.65, 0.65, "2019年");
$pieGraph->Add($piePlot3D1);
$pieGraph->Add($piePlot3D2);
$pieGraph->Add($piePlot3D3);
$pieGraph->Add($piePlot3D4);
$pieGraph->Stroke();

BIN
images/car.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB