Javascript 无法读取属性google图表
我想通过JSON设置google图表,但目前它不起作用。该网页无法读取未定义的“1”属性。如何解决这个问题?提前感谢这是我的代码: 测试目的:(模型) 控制器: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:
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;