Search code examples
phpphpexcelpie-chart

PHPExcel Pie Chart Series Options 25% on primary axis


I was able to create 2 pie charts programmatically (im using PHP), using the PHPExcel library (no need to list the code since it's too large) but i can not find a way to increase the distance between the pie's pieces like in the picture below. Basically, im trying to programmatically increase the Series Options on primary axis by 25%.enter image description here


Solution

  • When you init new PHPExcel_Chart_DataSeries object, you can specified $plotStyle=true.

    public function __construct($plotType = null, $plotGrouping = null, $plotOrder = array(), $plotLabel = array(), $plotCategory = array(), $plotValues = array(), $plotDirection = null, $smoothLine = null, $plotStyle = null)
    

    For PHPExcel\Examples\33chartcreate-pie.php:88 it will be something like there:

    $series1 = new PHPExcel_Chart_DataSeries(
        PHPExcel_Chart_DataSeries::TYPE_PIECHART,
        NULL,                                                   
        range(0, count($dataSeriesValues1)-1),                  
        $dataSeriesLabels1,                                     
        $xAxisTickValues1,                                      
        $dataSeriesValues1,                                     
        null,
        null,
        true
    );
    

    In sources: https://github.com/PHPOffice/PHPExcel/blob/1.8/Classes/PHPExcel/Writer/Excel2007/Chart.php#L1169