Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法读取属性google图表_Javascript_Php_Codeigniter_Google Visualization - Fatal编程技术网

Javascript 无法读取属性google图表

Javascript 无法读取属性google图表,javascript,php,codeigniter,google-visualization,Javascript,Php,Codeigniter,Google Visualization,我想通过JSON设置google图表,但目前它不起作用。该网页无法读取未定义的“1”属性。如何解决这个问题?提前感谢这是我的代码: 测试目的:(模型) 控制器: public function getProjects(){ $this->load->model('mreport'); $results = $this->mreport->getBilling(); echo json_encode($results); } HTML:

我想通过JSON设置google图表,但目前它不起作用。该网页无法读取未定义的“1”属性。如何解决这个问题?提前感谢这是我的代码:

测试目的:(模型)

控制器:

    public function getProjects(){
    $this->load->model('mreport');
    $results = $this->mreport->getBilling();
    echo json_encode($results);

}
HTML:



您的JSON字符串配置不正确。请尝试以下方法:

$table = array();
$table['cols'] = array(
    array('label' => 'Name', 'type' => 'string'),
    array('label' => 'Value', 'type' => 'number')
);

$PR = $CO = $IN = $SP = $SC = 5;

$table['rows'] = array();
$temp = array();
$temp[] = array('v' => 'PR'); 
$temp[] = array('v' => $PR);
$table['rows'][] = array('c' => $temp);

$temp = array();
$temp[] = array('v' => 'CO'); 
$temp[] = array('v' => $CO);
$table['rows'][] = array('c' => $temp);

$temp = array();
$temp[] = array('v' => 'SCC'); 
$temp[] = array('v' => $SC);
$table['rows'][] = array('c' => $temp);

$temp = array();
$temp[] = array('v' => 'IN'); 
$temp[] = array('v' => $IN);
$table['rows'][] = array('c' => $temp);

$temp = array();
$temp[] = array('v' => 'SP'); 
$temp[] = array('v' => $SP);
$table['rows'][] = array('c' => $temp);

return $table;

您的JSON字符串配置不正确。请尝试以下方法:

$table = array();
$table['cols'] = array(
    array('label' => 'Name', 'type' => 'string'),
    array('label' => 'Value', 'type' => 'number')
);

$PR = $CO = $IN = $SP = $SC = 5;

$table['rows'] = array();
$temp = array();
$temp[] = array('v' => 'PR'); 
$temp[] = array('v' => $PR);
$table['rows'][] = array('c' => $temp);

$temp = array();
$temp[] = array('v' => 'CO'); 
$temp[] = array('v' => $CO);
$table['rows'][] = array('c' => $temp);

$temp = array();
$temp[] = array('v' => 'SCC'); 
$temp[] = array('v' => $SC);
$table['rows'][] = array('c' => $temp);

$temp = array();
$temp[] = array('v' => 'IN'); 
$temp[] = array('v' => $IN);
$table['rows'][] = array('c' => $temp);

$temp = array();
$temp[] = array('v' => 'SP'); 
$temp[] = array('v' => $SP);
$table['rows'][] = array('c' => $temp);

return $table;
$table = array();
$table['cols'] = array(
    array('label' => 'Name', 'type' => 'string'),
    array('label' => 'Value', 'type' => 'number')
);

$PR = $CO = $IN = $SP = $SC = 5;

$table['rows'] = array();
$temp = array();
$temp[] = array('v' => 'PR'); 
$temp[] = array('v' => $PR);
$table['rows'][] = array('c' => $temp);

$temp = array();
$temp[] = array('v' => 'CO'); 
$temp[] = array('v' => $CO);
$table['rows'][] = array('c' => $temp);

$temp = array();
$temp[] = array('v' => 'SCC'); 
$temp[] = array('v' => $SC);
$table['rows'][] = array('c' => $temp);

$temp = array();
$temp[] = array('v' => 'IN'); 
$temp[] = array('v' => $IN);
$table['rows'][] = array('c' => $temp);

$temp = array();
$temp[] = array('v' => 'SP'); 
$temp[] = array('v' => $SP);
$table['rows'][] = array('c' => $temp);

return $table;