Reputation: 1213
I'm trying to generate a line chart, but part of my values are negative ones. The chart is rendered correctly, but the tick labels on the X axis are displaced. It seems that by default they're placed few pixels below X=0.
$objWorksheet->fromArray(
array(
array('', 2010, 2011, 2012),
array('Q1', 12, 15, 21),
array('Q2', -20, 73, 86),
array('Q3', -50, 61, 69),
array('Q4', 30, 32, 0),
)
);
Result:
Using OpenOffice when I'm editing the chart, I can right click on the X=0 line => Format Axis => Positioning => Labels, and by default the generated chart have selected 'Near axis'. When I change this to 'Outside start' for example, the result is:
How can this be done using PHPExcel?
Upvotes: 2
Views: 735
Reputation: 1213
I finally solved my question. If anyone is experiencing the same bug, applying the following fix until this becomes configurable solves the problem:
In file Classes/PHPExcel/Writer/Excel2007/Chart.php
, function _writeCatAx
, line 506
in my revision. Right after $objWriter->startElement('c:tickLblPos');
I had line $objWriter->writeAttribute('val', "nextTo");
.
The fix is changing nextTo
to low
.
PHPExcel is a great piece of software, but having this kind of stuff configurable is a must.
Upvotes: 4