栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Google Chart From Php变量

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Google Chart From Php变量

对于Visualization API的DataTable构造函数,您的数据结构不正确。

对于列正确的格式是列对象的数组,其中每个对象具有

type
(强制), ,
label
id
p
(所有可选)属性。
type
是可能的值的字符串
string
number
boolean
date
datetime
,和
timeofday

label
并且
id
是字符串。
p
是列属性的对象。

行的正确格式是行对象的数组,其中每个对象都有

c
p
属性。
c
是单元格对象的数组。
p
是行属性的对象。单元格对象具有
v
f
p
属性,其中
v
是单元格的值,是单元格
f
的字符串格式的值,并且
p
是单元格属性的对象。

所有属性对象支持的属性都取决于您所绘制的图表类型。

使用PHP的

json_enpre
功能,将关联数组转换为对象,将非关联数组转换为数组。表的适当结构应如下所示:

$columns = array(    array('type' => 'string', 'label' => 'x'),    array('type' => 'number', 'label' => 'values'),    // each interval should have its own unique id,    // but leaving them the same won't break anything for your chart as-is    array('type' => 'number', 'id' => 'i1', 'p' => array('role' => 'interval')),    array('type' => 'number', 'id' => 'i1', 'p' => array('role' => 'interval')),    array('type' => 'number', 'label' => 'OtherValues'),    array('type' => 'number', 'id' => 'i1', 'p' => array('role' => 'interval')),    array('type' => 'number', 'id' => 'i1', 'p' => array('role' => 'interval')));$test = array(    array('c' => array(        array('v' => 'a'),        array('v' => 100),        array('v' => 90),        array('v' => 150),        array('v' => 15),        array('v' => 10),        array('v' => 20)    )),    // etc);$table['cols'] = $columns;$table['rows'] = $test;


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/650013.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号