ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
33chartcreate-radar.php
Go to the documentation of this file.
1<?php
2
4error_reporting(E_ALL);
5ini_set('display_errors', TRUE);
6ini_set('display_startup_errors', TRUE);
7date_default_timezone_set('Europe/London');
8
9define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
10
11date_default_timezone_set('Europe/London');
12
40require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
41
42
44$objWorksheet = $objPHPExcel->getActiveSheet();
45$objWorksheet->fromArray(
46 array(
47 array('', 2010, 2011, 2012),
48 array('Jan', 47, 45, 71),
49 array('Feb', 56, 73, 86),
50 array('Mar', 52, 61, 69),
51 array('Apr', 40, 52, 60),
52 array('May', 42, 55, 71),
53 array('Jun', 58, 63, 76),
54 array('Jul', 53, 61, 89),
55 array('Aug', 46, 69, 85),
56 array('Sep', 62, 75, 81),
57 array('Oct', 51, 70, 96),
58 array('Nov', 55, 66, 89),
59 array('Dec', 68, 62, 0),
60 )
61);
62
63
64// Set the Labels for each data series we want to plot
65// Datatype
66// Cell reference for data
67// Format Code
68// Number of datapoints in series
69// Data values
70// Data Marker
72 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
73 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
74);
75// Set the X-Axis Labels
76// Datatype
77// Cell reference for data
78// Format Code
79// Number of datapoints in series
80// Data values
81// Data Marker
83 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$A$2:$A$13', NULL, 12), // Jan to Dec
84 new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$A$2:$A$13', NULL, 12), // Jan to Dec
85);
86// Set the Data values for each data series we want to plot
87// Datatype
88// Cell reference for data
89// Format Code
90// Number of datapoints in series
91// Data values
92// Data Marker
94 new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', NULL, 12),
95 new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', NULL, 12),
96);
97
98// Build the dataseries
101 NULL, // plotGrouping (Radar charts don't have any grouping)
102 range(0, count($dataSeriesValues)-1), // plotOrder
103 $dataSeriesLabels, // plotLabel
104 $xAxisTickValues, // plotCategory
105 $dataSeriesValues, // plotValues
106 NULL, // smooth line
108);
109
110// Set up a layout object for the Pie chart
112
113// Set the series in the plot area
115// Set the chart legend
117
118$title = new PHPExcel_Chart_Title('Test Radar Chart');
119
120
121// Create the chart
123 'chart1', // name
124 $title, // title
125 $legend, // legend
126 $plotArea, // plotArea
127 true, // plotVisibleOnly
128 0, // displayBlanksAs
129 NULL, // xAxisLabel
130 NULL // yAxisLabel - Radar charts don't have a Y-Axis
131);
132
133// Set the position where the chart should appear in the worksheet
134$chart->setTopLeftPosition('F2');
135$chart->setBottomRightPosition('M15');
136
137// Add the chart to the worksheet
138$objWorksheet->addChart($chart);
139
140
141// Save Excel 2007 file
142echo date('H:i:s') , " Write to Excel2007 format" , EOL;
144$objWriter->setIncludeCharts(TRUE);
145$objWriter->save(str_replace('.php', '.xlsx', __FILE__));
146echo date('H:i:s') , " File written to " , str_replace('.php', '.xlsx', pathinfo(__FILE__, PATHINFO_BASENAME)) , EOL;
147
148
149// Echo memory peak usage
150echo date('H:i:s') , " Peak memory usage: " , (memory_get_peak_usage(true) / 1024 / 1024) , " MB" , EOL;
151
152// Echo done
153echo date('H:i:s') , " Done writing file" , EOL;
154echo 'File has been created in ' , getcwd() , EOL;
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
memory_get_peak_usage(true)/1024/1024)
const EOL
$dataSeriesValues
$xAxisTickValues
$dataSeriesLabels
$objPHPExcel
PHPExcel.
An exception for terminatinating execution or to throw for unit testing.
static createWriter(PHPExcel $phpExcel, $writerType='')
Create PHPExcel_Writer_IWriter.
Definition: IOFactory.php:132