altariamx2003
asked on
how to create a scatter graph with straight lines
Hi im working with phpexcel and im trying to create a excel file with a scatther graph with straight lines
this is the code that im using:
And this is the graph that i get:
but as you see the labels in the x-axis are bad, i want to produce something like this:
What im missing?? do i need to add something else in my code?
this is the code that im using:
$xAxisTickValues = array(
new PHPExcel_Chart_DataSeriesValues('Number', '\'Phase Envelope No. 1\'!$B$11:$B$'.$linea, NULL, 4), // Q1 to Q4
new PHPExcel_Chart_DataSeriesValues('Number', '\'Phase Envelope No. 1\'!$D$11:$D$'.$linea, NULL, 4), // Q1 to Q4
);
$dataSeriesValues = array(
new PHPExcel_Chart_DataSeriesValues('Number', '\'Phase Envelope No. 1\'!$C$11:$C$'.$linea, NULL, 4),
new PHPExcel_Chart_DataSeriesValues('Number', '\'Phase Envelope No. 1\'!$E$11:$E$'.$linea, NULL, 4),
);
// Build the dataseries
$series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_SCATTERCHART, // plotType
NULL, // plotGrouping (Scatter charts don't have any grouping)
range(0, count($dataSeriesValues)-1), // plotOrder
NULL, // plotLabel
$xAxisTickValues, // plotCategory
$dataSeriesValues, // plotValues
NULL, // smooth line
PHPExcel_Chart_DataSeries::STYLE_SMOOTHMARKER // plotStyle
);
// 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_TOPRIGHT, NULL, false);
$title = new PHPExcel_Chart_Title('Test Scatter Chart');
$yAxisLabel = new PHPExcel_Chart_Title('Value ($k)');
// Create the chart
$chart = new PHPExcel_Chart(
'chart1', // name
NULL, // title
NULL, // legend
$plotarea, // plotArea
true, // plotVisibleOnly
0, // displayBlanksAs
NULL, // xAxisLabel
NULL // yAxisLabel
);
// Set the position where the chart should appear in the worksheet
$chart->setTopLeftPosition('G10');
$chart->setBottomRightPosition('Q39');
// Add the chart to the worksheet
$objPHPExcel->getActiveSheet()->addChart($chart);
And this is the graph that i get:
but as you see the labels in the x-axis are bad, i want to produce something like this:
What im missing?? do i need to add something else in my code?
ASKER
hi ray
i made an example, the data is the same just i change the way how i load in the excel file-test3.php
and also this the excel file that the phpscript produce-filename.xlsx
i made an example, the data is the same just i change the way how i load in the excel file-test3.php
and also this the excel file that the phpscript produce-filename.xlsx
Thanks - I think I can work with that. Where can I download a copy of the PHPExcel scripts?
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
im gonna check the link
thx ray
thx ray
If we can get that, then we can experiment with it, and maybe find a workable solution.