Skip to content

cannot create pie chart [not able to bind value] #32

@sailendraw

Description

@sailendraw

Hi, i am highchart plugin to display the pie chart but not able to generate pie, if i assign static value then pie chart is generated how ever when i pass php array it prints single line. here is my controller code.
$rawpercentage=$this->ConsumptionStock->query("select material_id,sum(quantity)*100/(select sum(quantity) from polychem.consumption_stock) as rawpercentage from polychem.consumption_stock group by material_id order by consumption_id;");
//Configure::write(‘debug’,0);
$this->set('rpercentage',$rawpercentage);
$rows = array();
foreach($rawpercentage as $raw):
$row[0] = $raw['consumption_stock']['material_id'];
$row[1] = $raw['0']['rawpercentage'];
array_push($rows,$row);
endforeach;
$dec=json_encode($rows, JSON_NUMERIC_CHECK);
$pieData[]=array();
array_push($pieData,$rows);
print_r($pieData);
//$pieData = $dec;
$chartName = 'Pie Chart';

            $pieChart = $this->Highcharts->create($chartName, 'pie');

            $this->Highcharts->setChartParams($chartName, array(
                'renderTo' => 'piewrapper', // div to display chart inside
                'chartWidth' => 600,
                'chartHeight' => 600,
                'chartMarginTop' => 60,
                'chartMarginLeft' => 90,
                'chartMarginRight' => 30,
                'chartMarginBottom' => 110,
                'chartSpacingRight' => 10,
                'chartSpacingBottom' => 15,
                'chartSpacingLeft' => 0,
                'chartAlignTicks' => FALSE,
                'chartBackgroundColorLinearGradient' => array(0, 0, 0, 300),
                'chartBackgroundColorStops' => array(array(0, 'rgb(217, 217, 217)'), array(1, 'rgb(255, 255, 255)')),
                'title' => 'Material Usage Statistics',
                'titleAlign' => 'left',
                'titleFloating' => TRUE,
                'titleStyleFont' => '18px Metrophobic, Arial, sans-serif',
                'titleStyleColor' => '#0099ff',
                'titleX' => 20,
                'titleY' => 20,
                'legendEnabled' => TRUE,
                'legendLayout' => 'horizontal',
                'legendAlign' => 'center',
                'legendVerticalAlign ' => 'bottom',
                'legendItemStyle' => array('color' => '#222'),
                'legendBackgroundColorLinearGradient' => array(0, 0, 0, 25),
                'legendBackgroundColorStops' => array(array(0, 'rgb(217, 217, 217)'), array(1, 'rgb(255, 255, 255)')),
                'tooltipEnabled' => TRUE,
                'tooltipBackgroundColorLinearGradient' => array(0, 0, 0, 50), // triggers js error
                'tooltipBackgroundColorStops' => array(array(0, 'rgb(217, 217, 217)'), array(1, 'rgb(255, 255, 255)')),
                'exportingEnabled' => FALSE
                    )
            );

            $series = $this->Highcharts->addChartSeries();

            $series->addName('Material Consumption')
                    ->addData($pieData);

            $pieChart->addSeries($series);

            $this->set(compact('chartName'));

please help me with this, i am new to both higchart and cakephp so any help would be really great favor to me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions