Wednesday, October 5, 2022

[FIXED] how to set a secondary axis to a data series in PHPEXCEL?

Issue

how to set a secondary axis for this series?

    $series = new PHPExcel_Chart_DataSeries(
        PHPExcel_Chart_DataSeries::TYPE_LINECHART,      // plotType
        PHPExcel_Chart_DataSeries::GROUPING_CLUSTERED,  // plotGrouping
        $chartOrder,                                    // plotOrder
        $chartLables,                                   // plotLabel
        $chartCategories,                               // plotCategory
        $chartValues                                    // plotValues
    );
    $series->setPlotDirection(PHPExcel_Chart_DataSeries::DIRECTION_COL);
    $plotarea = new PHPExcel_Chart_PlotArea(null, array($series));
    $legend = new PHPExcel_Chart_Legend(PHPExcel_Chart_Legend::POSITION_BOTTOM, null, false);

    $chart = new PHPExcel_Chart(
        "chart_$topRow_$leftColumn",                    // name
        null,                                           // title
        $legend,                                        // legend
        $plotarea,                                      // plotArea
        true,                                           // plotVisibleOnly
        0,                                              // displayBlanksAs
        null,                                           // xAxisLabel
        null                                            // yAxisLabel
    );
    $chart->setTopLeftPosition('A1');
    $chart->setBottomRightPosition(K12');
    $objWorksheet->addChart($chart);

Solution

You can't, secondary Y-axes are not yet supported.... remember that charting is still considered experimental, and chart functionality is still being built



Answered By - Mark Baker
Answer Checked By - Candace Johnson (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.