2014-10-24 00:39



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.

                array('',       2010,   2011,   2012),
                array('Q1',   12,   15,         21),
                array('Q2',   -20,   73,         86),
                array('Q3',   -50,   61,         69),
                array('Q4',   30,   32,         0),


wrong tick labels position

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:

wanna be labels position

How can this be done using PHPExcel?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dongzhuji1042 dongzhuji1042 7年前

    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.

    点赞 2 评论 复制链接分享