Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
更改PHPEXCEL中Y轴的对齐方式_Php_Charts_Phpexcel - Fatal编程技术网

更改PHPEXCEL中Y轴的对齐方式

更改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);

以下是我使用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);
        $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);