无法使用php使用canvaschart js从php数组中获取x轴和y轴数据或值

first page screen shots

second page screen shots not able to display the x- axis and y-axis data from array in canvaschart js using php or zendframework and mysql

<?php 
namespace Dashboard\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Session\Container;
use Application\Entity\PyPayGroup;
use Application\Entity\PyPayPeriod;
use Zend\Session\SessionManager;
use Application\Entity\CommonCompanyHeader;
use Dashboard\Form\PayrollspendForm;
class PayrollspendController  extends AbstractActionController
{
private $entityManager;
private $payrollspendManager;
private $sessionContainer;
private $pyPayPeriodClass;
private $pyPayGroupClass;
private $companyClass;
public function __construct($entityManager,$payrollspendManager)
{
$this->payrollspendManager = $payrollspendManager;
$this->entityManager = $entityManager;
$this->pyPayGroupClass = $this->entityManager->getRepository(PyPayGroup::class);
$this->pyPayPeriodClass = $this->entityManager->getRepository(PyPayPeriod::class);
$this->companyClass = $this->entityManager->getRepository(CommonCompanyHeader::class);
$sessionManager = new SessionManager();
$this->sessionContainer = new Container('ContainerNamespace', $sessionManager);
$arrLabel =  ['payroll_calendar','label_payroll_group','emp_id','emp_name','label_total_earnings','label_payroll_period','company','label_process_id','session_id','label_employer_contribution','pay_item'];
}
public function addAction()
{
    if ($this->sessionContainer->empId == "") {
        return $this->redirect()->toRoute('admin_user_login');
    }
    if (!in_array('PY', $this->sessionContainer->arrRole)) {

        if (!in_array('py_admin', $this->sessionContainer->arrRole)) {

            return $this->redirect()->toRoute('dashboard_ess_index');
         }
    }
   $reportForm = new PayrollspendForm();
   $payGroup = $this->pyPayGroupClass->findBy([
        'ouCode' => $this->sessionContainer->ouCode,
        'langCode' => $this->sessionContainer->langCode,
        'pgActive' => 1
    ]);
    $reportForm->buildPayGroupData($payGroup);
    $company = $this->companyClass->findBy([
        'ouCode' => $this->sessionContainer->ouCode,
        'langCode' => $this->sessionContainer->langCode
    ]);
    $reportForm->buildCompanyData($company);
    $payPeriodData = ['' => 'Select'];
    $reportForm->get('payPeriod')->setValueOptions($payPeriodData);
    $postData = $this->getRequest()->getPost()->toArray();
    $postData['ouCode'] = $this->sessionContainer->ouCode;
    $postData['langCode'] = $this->sessionContainer->langCode;
    $compData   = $this->payrollspendManager->buildCTCCompensationData($postData);
$groupByData = [
        '' => 'Select',
        'location' => 'Location',
        'department' => 'Department',
        'cost-center' => 'Cost center'
    ];
    $reportForm->get('groupby')->setValueOptions($groupByData);
     return new ViewModel([
        'form' => $reportForm,
        'ouCode' => $this->sessionContainer->ouCode,
        'reportData' =>  $compData ,
        'langCode' => $this->sessionContainer->langCode,
     ]);
}

This is model 
public function getAllCTCCompensationData($postData)
{ 

    $queryBuilder = $this->entityManager->createQueryBuilder();


    $queryBuilder->select('ppp.payperiodSdesc , ppesa.grossPay, pptpp.pfEmployerContribution, pptpp.esiEmployerContribution, pplw.employercontribution')
    ->from(PyProcessEmpStatusApproved::class, 'ppesa')
    ->leftJoin(PyProcessTdsPfPt::class, 'pptpp', 'with', 'ppesa.ouCode = pptpp.ouCode')
    ->leftJoin(PyPayGroup::class, 'ppg', 'with', 'pptpp.pgCode = ppg.pgCode')
    ->leftJoin(PyProcessLabourWelfare::class, 'pplw', 'with', 'ppg.pgCode = pplw.pgCode')
    ->leftJoin(PyPayPeriod::class,'ppp','with','pplw.payperiodCode = ppp.payperiodCode')
    ->leftJoin(PyPayrollCalendar::class, 'ppc', 'with', 'ppp.paycalCode = ppc.paycalCode')
            ->where('ppesa.ouCode = ?1')
            ->andWhere('ppesa.langCode = ?2')
            ->setParameter('1', $postData['ouCode'])
            ->setParameter('2', $postData['langCode'])
            ->setMaxResults(60);


$compData  = $queryBuilder->getQuery()->getResult();

$data = [];
if(!empty($compData))
{
$total = 0;
foreach($compData as $dataC)
{
$statData = $this->getStatuoryData($postData,$dataC['payperiodSdesc']);
if(isset($statData['payperiodSdesc']))
{
$data[$dataC['payperiodSdesc']]['PAYPERIOD'] = $this->payPERIODdata($postData,$dataC['payperiodSdesc']);

}
else 
{
$data[$dataC['payperiodSdesc']]['PAYPERIOD'] = $this->payPERIODdata($postData,$dataC['payperiodSdesc']);

}
if(isset($statData['pfEmployerContribution']))
{
$data[$dataC['payperiodSdesc']]['PF'] = $this->getPFData($postData,$dataC['payperiodSdesc']);
}
else 
{
$data[$dataC['payperiodSdesc']]['PF'] = $this->getPFData($postData,$dataC['payperiodSdesc']);
}
if(isset($statData['pfPensionFund']))
{
$data[$dataC['payperiodSdesc']]['PFF'] = $this->getPFData($postData,$dataC['payperiodSdesc']);
}
else 
{
$data[$dataC['payperiodSdesc']]['PFF'] = $this->getPFData($postData,$dataC['payperiodSdesc']);
}
if(isset($statData['grossPay']))
{

$data[$dataC['payperiodSdesc']]['GROSS'] = $this->getGROSSPAYData($postData,$dataC['payperiodSdesc']);
}
else 
{
$data[$dataC['payperiodSdesc']]['GROSS'] = $this->getGROSSPAYData($postData,$dataC['payperiodSdesc']);
}
if(isset($statData['employercontribution']))
{
$data[$dataC['payperiodSdesc']]['LABOURWELFARE'] = $this->getEMPLOYERCONTRIBUTIONData($postData,$dataC['payperiodSdesc']);
}
else 
{
$data[$dataC['payperiodSdesc']]['LABOURWELFARE'] = $this->getEMPLOYERCONTRIBUTIONData($postData,$dataC['payperiodSdesc']);
}
if(isset($statData['esiEmployerContribution']))
{
$data[$dataC['payperiodSdesc']]['ESIC'] = $this->getESICData($postData,$dataC['payperiodSdesc']);
}
else 
{
$data[$dataC['payperiodSdesc']]['ESIC'] =  $this->getESICData($postData,$dataC['payperiodSdesc']);
}
$data[$dataC['payperiodSdesc']]['Total'] = $this->getCTCCompensationSum($postData,

isset($data[$dataC['payperiodSdesc']]['payperiodSdesc']),
isset($data[$dataC['payperiodSdesc']]['pfEmployerContribution']),
isset($data[$dataC['payperiodSdesc']]['pfPensionFund']),
isset($data[$dataC['payperiodSdesc']]['esiEmployerContribution']),
isset($data[$dataC['payperiodSdesc']]['grossPay']),
isset($data[$dataC['payperiodSdesc']]['employercontribution']));
$data = [$data[$dataC['payperiodSdesc']]['Total']];
}
}
return $data;
}
This is view file or canvaschartjs 
<script>
window.onload = function () {
 var chart1 = new CanvasJS.Chart("chartContainer1", {
        animationEnabled: true,
        title: {
            text: ""
        },
        axisX: {
            labelFontColor: "#000000",
            labelFontStyle: "oblique",
        },
        axisY: {
            title: "",
            titleFontColor: "#4F81BC",
            lineColor: "#4F81BC",
            labelFontColor: "#4F81BC",
            tickColor: "#4F81BC"
        },
        axisY2: {
            title: "",
            titleFontColor: "#C0504E",
            lineColor: "#C0504E",
            labelFontColor: "#C0504E",
            tickColor: "#C0504E"
        },
        toolTip: {
            shared: true
        },
        legend: {
            cursor: "pointer",
            itemclick: toggleDataSeries
        },
        data: [{
                type: "column",
                name: "Total",
                legendText: "Total",
                showInLegend: true,
                dataPoints: [
                    <?php 
                    echo '<pre>';
                    print_r($compData);
                    die;
                    if(!empty($compData)) 
                    {
                    ?>
                    <?php
                    foreach($compData as $key => $value)
                     {

                    ?>
                        {label: "<?php echo $key; ?>", y:<?php echo $value[$data[$dataC['payperiodSdesc']]['Total']]; ?>},
                    <?php } ?>
                    <?php } ?>
                ]
            },
            {
                type: "column",
                name: "Closed",
                legendText: "Closed",
                showInLegend: true,
                dataPoints: [
                    <?php 
                    if(!empty($compData))
                    {
                    ?>
                    <?php
                    foreach($compData as $key => $value) 
                    {
                    ?>
                        {label: "<?php echo $key; ?>", y: <?php echo $value[$data[$dataC['payperiodSdesc']]['Total']]; ?>},
                    <?php } ?>
                    <?php } ?>
                ]
            },
            {
                type: "column",
                name: "Lapsed",
                legendText: "Lapsed",
                showInLegend: true,
                dataPoints: [
                    <?php if(!empty($compData)) { ?>
                    <?php foreach($compData as $key => $value) { ?>
                        {label: "<?php echo $key; ?>", y: <?php echo $value[$data[$dataC['payperiodSdesc']]['Total']]; ?>},
                    <?php } ?>
                    <?php } ?>
                ]
            }]
    });
}
    chart1.render();
    }
</script>




<script>
window.onload = function () {
 var chart1 = new CanvasJS.Chart("chartContainer1", {
        animationEnabled: true,
        title: {
            text: ""
        },
        axisX: {
            labelFontColor: "#000000",
            labelFontStyle: "oblique",
        },
        axisY: {
            title: "",
            titleFontColor: "#4F81BC",
            lineColor: "#4F81BC",
            labelFontColor: "#4F81BC",
            tickColor: "#4F81BC"
        },
        axisY2: {
            title: "",
            titleFontColor: "#C0504E",
            lineColor: "#C0504E",
            labelFontColor: "#C0504E",
            tickColor: "#C0504E"
        },
        toolTip: {
            shared: true
        },
        legend: {
            cursor: "pointer",
            itemclick: toggleDataSeries
        },
        data: [{
                type: "column",
                name: "Total",
                legendText: "Total",
                showInLegend: true,
                dataPoints: [
                    <?php 
                    echo '<pre>';
                    print_r($compData);
                    die;
                    if(!empty($compData)) 
                    {
                    ?>
                    <?php
                    foreach($compData[0] as $key => $value)
                     {

                    ?>
                        {label: "<?php echo $key; ?>", y:<?php echo $value[$data[$dataC['payperiodSdesc']]['Total']]; ?>},
                    <?php } ?>
                    <?php } ?>
                ]
            },
            {
                type: "column",
                name: "Closed",
                legendText: "Closed",
                showInLegend: true,
                dataPoints: [
                    <?php 
                    if(!empty($compData))
                    {
                    ?>
                    <?php
                    foreach($compData[1] as $key => $value) 
                    {
                    ?>
                        {label: "<?php echo $key; ?>", y: <?php echo $value[$data[$dataC['payperiodSdesc']]['Total']]; ?>},
                    <?php } ?>
                    <?php } ?>
                ]
            },
            {
                type: "column",
                name: "Lapsed",
                legendText: "Lapsed",
                showInLegend: true,
                dataPoints: [
                    <?php if(!empty($compData)) { ?>
                    <?php foreach($compData[2] as $key => $value) { ?>
                        {label: "<?php echo $key; ?>", y: <?php echo $value[$data[$dataC['payperiodSdesc']]['Total']]; ?>},
                    <?php } ?>
                    <?php } ?>
                ]
            }]
    });
        function toggleDataSeries(e) {
        if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
            e.dataSeries.visible = false;
        } else {
            e.dataSeries.visible = true;
        }

    }
    chart1.render();
    }
</script>

I am trying to draw a barchart of months of x-axis and Total spend on y-axis in graph.In controller class the data which i m sending to the view is $compData = $this->payrollspendManager->buildCTCCompensationData($postData); The x-axis will show the month ie $data[$dataC['payperiodSdesc']]['PAYPERIOD'] and y-axis will show the total spend ie $data[$dataC['payperiodSdesc']]['Total']. This month and total spend you will find in model. Here i m using canvasjs using zendframework.Now my data ie $compData is send from controller to view file.This compData has 7 elements and i want to display the zero elemnet in y-axis and sixth element in x-axis. for canvasjs refer to https://canvasjs.com website using php. if anybody require more code ...will help you
what is the issue in the code? The graph should have both x-axis and y-axis. i m recieving the data in controller in the form of array($compData). This array i m sending it to view. Then the array goes in foreach loop and display the zero element from array on x axis and last field ie 6th element on y-axis. i m displaying the data on x and y-axis dynamically using canvas js chart. how to display the graph using canvaschart js ? if anybody not getting clear about question can ask more for clearty i m trying to draw a barchart of months of x-axis and Total spend on y-axis in graph .In controller class the data which i m sending to the view is $compData = $this->payrollspendManager->buildCTCCompensationData($postData); THe x-axis will show the month ie $data[$dataC['payperiodSdesc']]['PAYPERIOD'] and y-axis will show the total spend ie $data[$dataC['payperiodSdesc']]['Total'] .This month and total spend you will find in model. here i m using canvasjs using zendframework.Now my data ie $compData is send from controller to view file.This compData has 7 elements and i want to display the zero elemnet in y-axis and sixth element in x-axis. for canvasjs refer to https://canvasjs.com website using php.

i want to display the PAYPERIOD which is the first array from details array and Total from Details which is last array