更改PHPEXCEL中Y轴的对齐方式
以下是我使用PHPEXCEL生成图表的代码:更改PHPEXCEL中Y轴的对齐方式,php,charts,phpexcel,Php,Charts,Phpexcel,以下是我使用PHPEXCEL生成图表的代码: $categories = new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C'.$old_constant.':$C'.$new_constant); $values = new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$E'.$old_constant.':$E'.$new_constant);
$categories = new PHPExcel_Chart_DataSeriesValues('String', 'Worksheet!$C'.$old_constant.':$C'.$new_constant);
$values = new PHPExcel_Chart_DataSeriesValues('Number', 'Worksheet!$E'.$old_constant.':$E'.$new_constant);
$series = new PHPExcel_Chart_DataSeries(
PHPExcel_Chart_DataSeries::TYPE_BARCHART, // plotType
PHPExcel_Chart_DataSeries::GROUPING_CLUSTERED, // plotGrouping
array(0), // plotOrder
array(), // plotLabel
array($categories), // plotCategory
array($values) // plotValues
);
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
$layout = new PHPExcel_Chart_Layout();
$plotarea = new PHPExcel_Chart_PlotArea($layout, array($series));
$title = new PHPExcel_Chart_Title($row[meter_name]);
$yAxisLabel = new PHPExcel_Chart_Title('Energy Consumed (KWH)');
$xAxisLabel = new PHPExcel_Chart_Title('Day');
$chart = new PHPExcel_Chart('sample', $title, null, $plotarea,true,0,$xAxisLabel,$yAxisLabel);
$chart->setTopLeftPosition('M'.$old_constant);
$chart->setBottomRightPosition('Z'.($new_constant+5));
$constant=$constant+5;
$objPHPExcel->getActiveSheet()->addChart($chart);
这是我在excel中得到的输出图表:
我希望Y轴垂直对齐,而不是水平对齐。如有任何帮助,将不胜感激。然后尝试更改
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
到
列是垂直的(从上到下),条是水平的(从左到右)我不希望X轴和Y轴互换,我只希望标签垂直显示Y轴
$series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_BAR);