PHPExcel Radar Chart Main Axis Missing - phpexcel

I want to use phpexcel to draw a radar chart, but when I open the generated file with Microsoft Excel 2010, the chart's main axis is missing(like below image, the first is wrong, the second is correct).
The wrong chart draw by phpexcel
The correct chart draw by Excel 2010
Then I read phpexcel's examples '33chartcreate-radar.php', but it has the same problem.
How do I make the main axis show?
$excel = new PHPExcel();
$sheet = $excel->getActiveSheet();
$sheet->setTitle('sheet');
$data = [
['Direction', 'N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'],
['Frequency', 10, 20, 5, 10, 15, 30, 5, 5]
];
$sheet->fromArray($data, null, 'A1');
$dataseriesLabels = array(new PHPExcel_Chart_DataSeriesValues('String',
'sheet!$A$2', NULL, 1));
$xAxisTickValues = array(new PHPExcel_Chart_DataSeriesValues('String',
'sheet!$B$1:$I$1', NULL, 8));
$dataSeriesValues = array(new PHPExcel_Chart_DataSeriesValues('String',
'sheet!$B$2:$I$2', NULL, 8));
$series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_RADARCHART,
null,
range(0, count($dataSeriesValues)-1),
$dataseriesLabels,
$xAxisTickValues,
$dataSeriesValues,
null,
null,
PHPExcel_Chart_DataSeries::STYLE_MARKER
);
$plotarea = new PHPExcel_Chart_PlotArea(null, array($series));
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_TOPRIGHT,
NULL, false);
$title = new PHPExcel_Chart_Title('Wind Rose Diagram');
$chart = new PHPExcel_Chart(
'chart1',
$title,
$legend,
$plotarea,
true,
0,
null,
null
);
$chart->setTopLeftPosition('A7');
$chart->setBottomRightPosition('I32');
$sheet->addChart($chart);
$ExcelWrite = PHPExcel_IOFactory::createWriter($excel, "Excel2007");
$ExcelWrite->setIncludeCharts(true);
$ExcelWrite->save('D:\TestRadarChart.xlsx');

If Excel vba is OK, I could display it.
ActiveChart.Axes(xlCategory).hasMajorGridlines=true
Select the target chart on excel.
Press Alt+F11 on excel, then VBE opens.
Press Ctrl+G on VBE, then immediate window opens.
Paste the above code.
Place the cursor on the line of the code and press the enter key.
I made the file with PHPExcel and edit it with excel 2010.

I do not know about side effect, but it may be possible to fix it.
I confirmed with PHPExcel 1.8.0.
source:
Lib/PHPExcel/Classes/PHPExcel/Writer/Excel2007/Chart.php(450)
before:
$objWriter->startElement('c:axPos');
$objWriter->writeAttribute('val', "b");
$objWriter->endElement();
after:
$objWriter->startElement('c:axPos');
$objWriter->writeAttribute('val', "b");
$objWriter->endElement();
$objWriter->startElement('c:majorGridlines'); //added
$objWriter->endElement(); //added

Related

Align annotation text on Google Chart

I am trying to nudge my annotation text to the top of my line chart rather than middle. The annotations that I want to shift are associated with the x-axis data so appear rotated on a vertical line so it would seem like all I need to do is align the text to the right.
I am aware of the annotations.textStyle configuration option but there are no examples of aligment changes shown in the documentation and I've been trying out some options that I thought would work but nothing shifts it from the centre.
For example in this Fiddler I thought textStyle: {align: 'right'} would work but it has no impact - the annotation 'boost' is still showing in the centre rather than at the top.
there are no options available to adjust the alignment,
but you can manually modify the chart's svg,
when the chart's 'ready' event fires...
here, I find the annotation <text> element and adjust the x coordinate (due to the transformation)
google.charts.load('current', {
packages: ['corechart']
}).then(drawVisualization);
function drawVisualization() {
// example copied from Google Visualization API playground,
// modified for category axis annotations
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('string', 'x');
data.addColumn({type: 'string', role: 'annotation'});
data.addColumn({type: 'string', role: 'annotationText'});
data.addColumn('number', 'Cats');
data.addColumn('number', 'Blanket 1');
data.addColumn('number', 'Blanket 2');
data.addRow(["A", null, null, 1, 1, 0.5]);
data.addRow(["B", null, null, 2, 0.5, 1]);
data.addRow(["C", null, null, 4, 1, 0.5]);
data.addRow(["D", null, null, 8, 0.5, 1]);
data.addRow(["E", null, null, 7, 1, 0.5]);
data.addRow(["F", null, null, 7, 0.5, 1]);
data.addRow(["G", 'boost', 'Foo annotation', 8, 1, 0.5]);
data.addRow(["H", null, null, 4, 0.5, 1]);
data.addRow(["I", null, null, 2, 1, 0.5]);
data.addRow(["J", null, null, 3.5, 0.5, 1]);
data.addRow(["K", ' ', 'Bar annotation', 3, 1, 0.5]);
data.addRow(["L", null, null, 3.5, 0.5, 1]);
data.addRow(["M", null, null, 1, 1, 0.5]);
data.addRow(["N", null, null, 1, 0.5, 1]);
var chart = new google.visualization.LineChart(document.getElementById('visualization'));
google.visualization.events.addListener(chart, 'ready', function () {
var labels = chart.getContainer().getElementsByTagName('text');
Array.prototype.forEach.call(labels, function(label) {
if ((label.getAttribute('text-anchor') === 'middle') && (label.hasAttribute('transform'))) {
label.setAttribute('x', parseFloat(label.getAttribute('x')) + 100);
}
});
});
chart.draw(data, {
curveType: 'function',
width: 500,
height: 400,
vAxis: {
maxValue: 10
},
annotations: {
style: 'line',
}
});
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="visualization"></div>
note: the jsapi loader is an old version, use loader.js instead, see above...

Weird dataseries labels on legend chart

Today i'm working with phpexcel to generate some bar chart in my files.
Nevertheless, i dont get expected labels on my legend except the first :
Bad labels on legend
I dont get it because i put the right range in my dataseries labels array. Only the first label is right but others are by default "Series2, Serie3, ..."
This is my code :
// Each worksheet
foreach($tab_calcul as $calcul => $bool){
$tab_length_lig = ${"worksheet_$calcul"}->getHighestRow();
$tab_length_col = PHPExcel_Cell::columnIndexFromString(${"worksheet_$calcul"}->getHighestColumn())-1;
///////////////////////////////////////////////////////////////////////
//////////////// DATASERIES BY SHOP ////////////////////////
///////////////////////////////////////////////////////////////////////
// Shop labels
$dataseriesLabels = array(
new PHPExcel_Chart_DataSeriesValues('String', '$calcul!$A$4:$A$'.($tab_length_lig-1), NULL, $nb_enseigne)
);
// Dates
$xAxisTickValues = array(
new PHPExcel_Chart_DataSeriesValues('String', '$calcul!$C$3:$'.ch2al($tab_length_col).'$3', NULL, $nb_synthese)
);
// Values
$dataSeriesValues = array();
$cpt = 3;
for($i = 0; $i < count($tab_enseigne); $i++) {
$cpt++;
array_push($dataSeriesValues, new PHPExcel_Chart_DataSeriesValues('Number', '$calcul!$C$'.$cpt.':$'.ch2al($tab_length_col).'$'.$cpt, NULL, $nb_synthese));
}
// Build the dataseries
$series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STANDARD , // plotGrouping
range(0, count($dataSeriesValues)-1), // plotOrder
$dataseriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues
);
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COLUMN);
///////////////////////////////////////////////////////////////////////
/////////////// DATASERIES ALL SHOPS /////////////////////
///////////////////////////////////////////////////////////////////////
// Label all shops
$dataseriesLabels2 = array(
new PHPExcel_Chart_DataSeriesValues('String', '$calcul!$A$'.($tab_length_lig), NULL, 1)
);
// Values
$dataSeriesValues2 = array(
new PHPExcel_Chart_DataSeriesValues('Number', '$calcul!$C$'.$tab_length_lig.':$'.ch2al($tab_length_col).'$'.$tab_length_lig, NULL, $nb_synthese)
);
// Build the dataseries
$series2 = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_LINECHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STANDARD , // plotGrouping
range(0, count($dataSeriesValues2)-1), // plotOrder
$dataseriesLabels2, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues2 // plotValues
);
/////////////////////////////////////////////////////////////////////////
// Set the series in the plot area
$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series, $series2));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false);
$title = new PHPExcel_Chart_Title('Graphe '.$calcul." : ".utf8_encode($tab_data[$rmookid_periode]["marque"]." - ".$tab_data[$rmookid_periode]["modele"]." - ".$tab_data[$rmookid_periode]["ean"]));
// Create the chart
$chart = new PHPExcel_Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotarea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel
NULL // yAxisLabel
);
// Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('A17');
$chart->setBottomRightPosition('K30');
// Add the chart to the worksheet
${"worksheet_$calcul"}->addChart($chart);
}
Thank you in advance
I fixed it. It was a huge mistake to put $calcul in simple quote :
'$calcul!$A$'.($tab_length_lig)
Should be :
$calcul.'!$A$'.($tab_length_lig)

PHPExcel. Create chart that allows save it where i want

I am trying to combine two examples. eg1 and eg2 runs fine independently.
I would like to create a chart from php but allows me to save it where I want. But when I try to open always tells me it's corrupt or extension is not correct.
I have looked some answers to similar questions and have not been able to find appropriate solution.
What am I missing here?
Well, finally i did it.
Now the problem is, i can't rename the worksheet where i save the graph.
If i do that, Excel can't open the file.
The code:
<?php
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
/** PHPExcel */
require_once dirname(__FILE__) . '/../Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
$objWorksheet = $objPHPExcel->getActiveSheet();
$objWorksheet->fromArray(
array(
array('', 2010, 2011, 2012),
array('Q1', 12, 15, 21),
array('Q2', 56, 73, 86),
array('Q3', 52, 61, 69),
array('Q4', 30, 32, 0),
)
);
$dataseriesLabels = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // 2010
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // 2011
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // 2012
);
$xAxisTickValues = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$A$2:$A$5', NULL, 4), // Q1 to Q4
);
$dataSeriesValues = array(
new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$B$2:$B$5', NULL, 4),
new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$C$2:$C$5', NULL, 4),
new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$D$2:$D$5', NULL, 4),
);
// Build the dataseries
$series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping
range(0, count($dataSeriesValues)-1), // plotOrder
$dataseriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues
);
// Set additional dataseries parameters
// Make it a vertical column rather than a horizontal bar graph
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
// Set the series in the plot area
$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false);
$title = new PHPExcel_Chart_Title('Test Column Chart');
$yAxisLabel = new PHPExcel_Chart_Title('Value ($k)');
// Create the chart
$chart = new PHPExcel_Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotarea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel
$yAxisLabel // yAxisLabel
);
// Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('A7');
$chart->setBottomRightPosition('H20');
// Add the chart to the worksheet
$objWorksheet->addChart($chart);
$objPHPExcel->getActiveSheet()->setTitle('Probando');
// Save Excel 2007 file
// Redirect output to a client’s web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="01simple.xlsx"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->setIncludeCharts(TRUE);
$objWriter->save('php://output');
exit;
The line "$objPHPExcel->getActiveSheet()->setTitle('Probando');" is the problem, some idea?
PS: Sorry for my bad english.
#koky
Rename the sheet first, and then create the table and graph, like so:
<?php
/** Error reporting */
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
date_default_timezone_set('Europe/London');
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
date_default_timezone_set('Europe/London');
/** PHPExcel */
require_once dirname(__FILE__) . '/Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
$objWorksheet = $objPHPExcel->getActiveSheet();
$objPHPExcel->getActiveSheet()->setTitle('Probando');
$objWorksheet->fromArray(
array(
array('', 2010, 2011, 2012),
array('Q1', 12, 15, 21),
array('Q2', 56, 73, 86),
array('Q3', 52, 61, 69),
array('Q4', 30, 32, 0),
)
);
$dataseriesLabels = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Probando!$B$1', NULL, 1), // 2010
new PHPExcel_Chart_DataSeriesValues('String', 'Probando!$C$1', NULL, 1), // 2011
new PHPExcel_Chart_DataSeriesValues('String', 'Probando!$D$1', NULL, 1), // 2012
);
$xAxisTickValues = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Probando!$A$2:$A$5', NULL, 4), // Q1 to Q4
);
$dataSeriesValues = array(
new PHPExcel_Chart_DataSeriesValues('Number', 'Probando!$B$2:$B$5', NULL, 4),
new PHPExcel_Chart_DataSeriesValues('Number', 'Probando!$C$2:$C$5', NULL, 4),
new PHPExcel_Chart_DataSeriesValues('Number', 'Probando!$D$2:$D$5', NULL, 4),
);
// Build the dataseries
$series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping
range(0, count($dataSeriesValues)-1), // plotOrder
$dataseriesLabels, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues // plotValues
);
// Set additional dataseries parameters
// Make it a vertical column rather than a horizontal bar graph
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
// Set the series in the plot area
$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false);
$title = new PHPExcel_Chart_Title('Test Column Chart');
$yAxisLabel = new PHPExcel_Chart_Title('Value ($k)');
// Create the chart
$chart = new PHPExcel_Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotarea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel
$yAxisLabel // yAxisLabel
);
// Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('A7');
$chart->setBottomRightPosition('H20');
// Add the chart to the worksheet
$objWorksheet->addChart($chart);
// Save Excel 2007 file
// Redirect output to a client’s web browser (Excel2007)
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="01simple.xlsx"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->setIncludeCharts(TRUE);
$objWriter->save('php://output');
exit;
?>

How to get rid of numbers around the graph? PHPExcel

Is there a way to setup our graph so it will look like this .. http://www.epicstan.com/graf.jpg ?
We can't find out how to get rid of the number around our graph.
Here is the file that is generated http://www.epicstan.com/export.xlsx and on sheet 2 we need to change that graph look.
Here is the code ..
<?php
/* part of generater code */
/* charts */
$dataSeriesValues = array(
new \PHPExcel_Chart_DataSeriesValues('Number', 'sheet2!$I$'.(($i*5)+3).':$I$'.(($i*5)+5), NULL, 6),
);
// Build the dataseries
$series = new \PHPExcel_Chart_DataSeries(
\PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D, // plotType
NULL,
range(0, count($dataSeriesValues)-1),
NULL,
NULL,
$dataSeriesValues
);
$series->setPlotDirection(\PHPExcel_Chart_DataSeries::DIRECTION_BAR);
$layout = new \PHPExcel_Chart_Layout();
$layout->setManual3dAlign(true);
$layout->setXRotation(10);
$layout->setYRotation(20);
$layout->setRightAngleAxes(1);
$layout->setShowVal(true);
$plotarea = new \PHPExcel_Chart_PlotArea($layout, array($series));
$chart = new \PHPExcel_Chart(
'chart1',
NULL,
NULL,
$plotarea,
true,
0,
NULL,
NULL
);
$chart->setTopLeftPosition('I'.(($i*5)+2));
$chart->setBottomRightPosition('J'.(($i*5)+8));
$excel->getActiveSheet()->addChart($chart);
$excel->setActiveSheetIndex(0);
$objWriter = new \PHPExcel_Writer_Excel2007($excel);
$objWriter->setIncludeCharts(TRUE);
$file = DOWNLOAD_DIR . 'export.xlsx';
$objWriter->save($file);
Thank you.
Peter
Change your arguments for the dataseries constructor to set an empty series of string plotCategories:
// Build the dataseries
$series = new \PHPExcel_Chart_DataSeries(
\PHPExcel_Chart_DataSeries::TYPE_BARCHART_3D, // plotType
NULL,
range(0, count($dataSeriesValues)-1),
NULL,
new \PHPExcel_Chart_DataSeriesValues(
'String',
NULL,
NULL,
count($dataSeriesValues)
),
$dataSeriesValues
);

Php Excel, bar and line graph possibility?

Is it possible to create a line and bar graph using PHPExcel? Like this one below.
If not is it possible to make a graph background transparent so I can merge two graphs together?
I had to make a minor tweak to the PHPExcel code to get it working correctly, just pushed it to github; together with 33chartcreate-composite-chart.php in /Examples.
$objPHPExcel = new PHPExcel();
$objWorksheet = $objPHPExcel->getActiveSheet();
$objWorksheet->fromArray(
array(
array('', 'Rainfall (mm)', 'Temperature (°F)', 'Humidity (%)'),
array('Jan', 78, 52, 61),
array('Feb', 64, 54, 62),
array('Mar', 62, 57, 63),
array('Apr', 21, 62, 59),
array('May', 11, 75, 60),
array('Jun', 1, 75, 57),
array('Jul', 1, 79, 56),
array('Aug', 1, 79, 59),
array('Sep', 10, 75, 60),
array('Oct', 40, 68, 63),
array('Nov', 69, 62, 64),
array('Dec', 89, 57, 66),
)
);
// Set the Labels for each data series we want to plot
// Datatype
// Cell reference for data
// Format Code
// Number of datapoints in series
// Data values
// Data Marker
$dataseriesLabels1 = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$B$1', NULL, 1), // Temperature
);
$dataseriesLabels2 = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C$1', NULL, 1), // Rainfall
);
$dataseriesLabels3 = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$D$1', NULL, 1), // Humidity
);
// Set the X-Axis Labels
// Datatype
// Cell reference for data
// Format Code
// Number of datapoints in series
// Data values
// Data Marker
$xAxisTickValues = array(
new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$A$2:$A$13', NULL, 12), // Jan to Dec
);
// Set the Data values for each data series we want to plot
// Datatype
// Cell reference for data
// Format Code
// Number of datapoints in series
// Data values
// Data Marker
$dataSeriesValues1 = array(
new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$B$2:$B$13', NULL, 12),
);
// Build the dataseries
$series1 = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_CLUSTERED, // plotGrouping
range(0, count($dataSeriesValues1)-1), // plotOrder
$dataseriesLabels1, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues1 // plotValues
);
// Set additional dataseries parameters
// Make it a vertical column rather than a horizontal bar graph
$series1->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
// Set the Data values for each data series we want to plot
// Datatype
// Cell reference for data
// Format Code
// Number of datapoints in series
// Data values
// Data Marker
$dataSeriesValues2 = array(
new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$C$2:$C$13', NULL, 12),
);
// Build the dataseries
$series2 = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_LINECHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping
range(0, count($dataSeriesValues2)-1), // plotOrder
$dataseriesLabels2, // plotLabel
NULL, // plotCategory
$dataSeriesValues2 // plotValues
);
// Set the Data values for each data series we want to plot
// Datatype
// Cell reference for data
// Format Code
// Number of datapoints in series
// Data values
// Data Marker
$dataSeriesValues3 = array(
new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$D$2:$D$13', NULL, 12),
);
// Build the dataseries
$series3 = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_AREACHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_STANDARD, // plotGrouping
range(0, count($dataSeriesValues2)-1), // plotOrder
$dataseriesLabels3, // plotLabel
NULL, // plotCategory
$dataSeriesValues3 // plotValues
);
// Set the series in the plot area
$plotarea = new PHPExcel_Chart_PlotArea(NULL, array($series1, $series2, $series3));
// Set the chart legend
$legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_RIGHT, NULL, false);
$title = new PHPExcel_Chart_Title('Average Weather Chart for Crete');
// Create the chart
$chart = new PHPExcel_Chart(
'chart1', // name
$title, // title
$legend, // legend
$plotarea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel
NULL // yAxisLabel
);
// Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('F2');
$chart->setBottomRightPosition('O16');
// Add the chart to the worksheet
$objWorksheet->addChart($chart);

Resources