2014-10-02 49 views
4

我正在使用PHPExcel以導出帶有條形圖的Excel圖表。PHPExcel Chart不反轉縱軸

我可以將圖表與默認佈局這個圖片導出:

enter image description here

但是,我要讓在圖表的頂部軸線佈局和反向Y軸爲這一形象:

enter image description here

我怎麼能這樣做?

$yAxis = new \PHPExcel_Chart_Axis(); 
$yAxis->setsetAxisOptionsProperties(
    \PHPExcel_Chart_Axis::AXIS_LABELS_NEXT_TO, 
    null, 
    null, 
    \PHPExcel_Properties::ORIENTATION_REVERSED 
); 

$chart = new \PHPExcel_Chart(
    "Chart1", 
    $titile, 
    $legend, 
    $plotArea, 
    true, 
    '0', 
    null, 
    null, 
    null, //xAxis parameter if you want to reverse the x axis 
    $yAxis 
); 

注意

+2

即選項不可用在目前的時間:

然而扭轉軸不能通過預期工作的其它方法來實現 – 2014-10-02 07:54:40

回答

1

研究,我發現,這是可能扭轉軸中的代碼後如果串聯方向設置爲列,而不是酒吧

$series = new \PHPExcel_Chart_DataSeries(....); 
$series->setPlotDirection(\PHPExcel_Chart_DataSeries::DIRECTION_COL); 

軸相反,所以您設置爲Y軸的選項將應用於X軸和相反。

$chart->getChartAxisY()->setAxisOrientation(\PHPExcel_Properties::ORIENTATION_REVERSED); 

$yAxis = new \PHPExcel_Chart_Axis(); 
$yAxis->setAxisOrientation(\PHPExcel_Properties::ORIENTATION_REVERSED); 

$chart = new \PHPExcel_Chart(
    "Chart1", 
    $titile, 
    $legend, 
    $plotArea, 
    true, 
    '0', 
    null, 
    null, 
    null, //xAxis parameter if you want to reverse the x axis 
    $yAxis 
);