Not all Chart values are shown

Topics: User Forum
Oct 11, 2012 at 12:52 AM
Edited Oct 11, 2012 at 12:55 AM

I'm using the sample from this discussion and essentially expanding the data that needs to be shown in the chart. However, the chart is not displaying anything beyond the second column (column D).

I've tried different ways to go about it - 

Removed the middle column, changed the headings of the labels and categories and also outputted the plotValues using the getPlotValues() function to see if the proper description got populated, and there's no luck in figuring out why all series values are not being selected for the chart.

 

 

$excel->getActiveSheet()->fromArray(array(
    $header ,
    array('Central',   12,   15 , 12 ),
    array('Northeast',   56,   73 , 10 ),
    array('Southeast',   52,   61 , 33 ),
    array('Western',   30,   32 , 55 ),
));
					

$labels = array(
    new PHPExcel_Chart_DataSeriesValues('String', 'Summary!$B$1', null, 1),
    new PHPExcel_Chart_DataSeriesValues('String', 'Summary!$C$1', null, 1),
    new PHPExcel_Chart_DataSeriesValues('String', 'Summary!$D$1', null, 1),
);

$categories = array(
    new PHPExcel_Chart_DataSeriesValues('String', 'Summary!$A$2:$A$5', null, 4),
);
                                        
// this is where the problem arises - the third DataSeriesValues is not being displayed
$values = array(
    new PHPExcel_Chart_DataSeriesValues('Number', 'Summary!$B$2:$B$5', null, 4),
    new PHPExcel_Chart_DataSeriesValues('Number', 'Summary!$C$2:$C$5', null, 4),
    new PHPExcel_Chart_DataSeriesValues('Number', 'Summary!$D$2:$D$5', null, 4),
/*
    new PHPExcel_Chart_DataSeriesValues('Number', 'Summary!$C$2:$C$5', null, 5),
    new PHPExcel_Chart_DataSeriesValues('Number', 'Summary!$D$2:$D$5', null, 5)
    new PHPExcel_Chart_DataSeriesValues('Number', 'Summary!$E$2:$E$5', null, 5),
    new PHPExcel_Chart_DataSeriesValues('Number', 'Summary!$F$2:$F$5', null, 5),
*/
);

$series = new PHPExcel_Chart_DataSeries(
    PHPExcel_Chart_DataSeries::TYPE_BARCHART,       // plotType
    PHPExcel_Chart_DataSeries::GROUPING_CLUSTERED,  //      plotGrouping
    array(0, 1),                                    // plotOrder
    $labels,                                        // plotLabel
    $categories,                                    // plotCategory
    $values                                         // 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_RIGHT, null, false);
					
					
$chart = new PHPExcel_Chart(
    'chart1',                                       // name
    null,                                           // title
    $legend,                                        // legend
    $plotarea,                                      // plotArea
    true,                                           // plotVisibleOnly
    0,                                              // displayBlanksAs
    null,                                           // xAxisLabel
    null                                            // yAxisLabel
);
					
$chart->setTopLeftPosition('A7');
$chart->setBottomRightPosition('H20');
$excel->getActiveSheet()->addChart($chart);
$excel->getActiveSheet()->setTitle("Summary");


Coordinator
Oct 11, 2012 at 8:54 AM
   array(0, 1, 2),                                    // plotOrder

or

range(0,count($values)-1)

 

Oct 11, 2012 at 11:45 AM

Ha - thank you - I saw you posted on Stackoverflow as well - appreciate the double response.