统计图表类库--libchart使用简介

1.饼图

#载入类文件
include "../libchart/classes/libchart.php";
header("Content-type: image/png");
$chart = new PieChart(500, 300);
$dataSet = new XYDataSet();
#添加数据
$dataSet->addPoint(new Point("Bleu d'Auvergne", 50));
$dataSet->addPoint(new Point("Tomme de Savoie", 75));
$dataSet->addPoint(new Point("Crottin de Chavignol", 30));
#设置图表信息
$chart->setDataSet($dataSet);
$chart->setTitle("Preferred Cheese");
#输出图表
$chart->render();

统计图表类库--libchart使用简介

2.横向柱形图

#载入类文件
include "../libchart/classes/libchart.php";
$chart = new HorizontalBarChart(600, 170);
$dataSet = new XYDataSet();
#添加数据
$dataSet->addPoint(new Point("/wiki/Instant_messenger", 50));
$dataSet->addPoint(new Point("/wiki/Web_Browser", 75));
$dataSet->addPoint(new Point("/wiki/World_Wide_Web", 122));
#设置并输出
$chart->setDataSet($dataSet);
$chart->getPlot()->setGraphPadding(new Padding(5, 30, 20, 140));
$chart->setTitle("Most visited pages for www.example.com");
$chart->render();

统计图表类库--libchart使用简介

3.纵向柱形图

#载入类文件
include "../libchart/classes/libchart.php";
$chart = new VerticalBarChart();
$dataSet = new XYDataSet();
#添加数据
$dataSet->addPoint(new Point("Jan 2005", 273));
$dataSet->addPoint(new Point("Feb 2005", 421));
$dataSet->addPoint(new Point("March 2005", 642));
$dataSet->addPoint(new Point("April 2005", 800));
$dataSet->addPoint(new Point("May 2005", 1200));
$dataSet->addPoint(new Point("June 2005", 1500));
$dataSet->addPoint(new Point("July 2005", 2600));
#设置并输出
$chart->setDataSet($dataSet);
$chart->setTitle("Monthly usage for www.example.com");
$chart->render();

统计图表类库--libchart使用简介

4.折线图

#载入类文件
include "../libchart/classes/libchart.php";
$chart = new LineChart();
$dataSet = new XYDataSet();
#添加数据
$dataSet->addPoint(new Point("06-01", 273));
$dataSet->addPoint(new Point("06-02", 421));
$dataSet->addPoint(new Point("06-03", 642));
$dataSet->addPoint(new Point("06-04", 799));
$dataSet->addPoint(new Point("06-05", 1009));
$dataSet->addPoint(new Point("06-06", 1406));
$dataSet->addPoint(new Point("06-07", 1820));
$dataSet->addPoint(new Point("06-08", 2511));
$dataSet->addPoint(new Point("06-09", 2832));
$dataSet->addPoint(new Point("06-10", 3550));
$dataSet->addPoint(new Point("06-11", 4143));
$dataSet->addPoint(new Point("06-12", 4715));
#设置并输出
$chart->setDataSet($dataSet);
$chart->setTitle("Sales for 2006");
$chart->render();

统计图表类库--libchart使用简介

上一篇:JavaRMI入门和使用


下一篇:Java项目运维总结记录