javascript - 了解 Google DataTable 前缀

标签 javascript google-datatable

Google DataTable 将此字符串作为架构和数据值:

{ 
cols: [{id: 'task',  label: 'Task',          type: 'string'}, 
      {id: 'hours', label: 'Hours per Day', type: 'number'}], 
rows: [{c:[{v: 'Work'},     {v: 11}]}, 
      {c:[{v: 'Eat'},      {v: 2}]}, 
      {c:[{v: 'Commute'},  {v: 2}]}, 
      {c:[{v: 'Watch TV'}, {v:2}]}, 
      {c:[{v: 'Sleep'},    {v:7, f:'7.000'}]} 
     ] 
} 

什么是 v、f、c?

最佳答案

documentation ,看起来,你从中得到了例子,链接到结构的描述:

opt_data
[Optional] Data used to initialize the table. This can either be the JSON returned by calling DataTable.toJSON() on a populated table, or a JavaScript object containing data used to initialize the table. The structure of the JavaScript literal object is described here. If this parameter is not supplied, a new, empty data table will be returned.

这导致:

rows Property

The rows property holds an array of row objects.
Each row object has one required property called c, which is an array of cells in that row. It also has an optional p property that defines a map of arbitrary custom values to assign to the whole row. If your visualization supports any row-level properties it will describe them; otherwise, this property will be ignored.

Cell Objects

Each cell in the table is described by an object with the following properties:

  • v [Optional] The cell value. The data type should match the column data type. If null, the whole object should be empty and have neither v nor f properties.
  • f [Optional] A string version of the v value, formatted for display. The values should match, so if you specify Date(2008, 0, 1) for v, you should specify "January 1, 2008" or some such string for this property. This value is not checked against the v value. The visualization will not use this value for calculation, only as a label for display. If omitted, a string version of v will be used.
  • p [Optional] An object that is a map of custom values applied to the cell. These values can be of any JavaScript type. If your visualization supports any cell-level properties, it will describe them; otherwise, this property will be ignored. Example: p:{style: 'border: 1px solid green;'}.

关于javascript - 了解 Google DataTable 前缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6896418/

相关文章:

datatable - Google DataTable 的 getRow() 方法是否已弃用?

javascript - 有没有办法使用 JavaScript 关闭文件上传对话框?

javascript - 将 google.visualization.datatable 与复选框和 KnockOut 数据绑定(bind)相结合

javascript - 在 Google Visualization API 中使用 Group By Aggregation 保留格式

javascript - 如何在启动 funcC() 之前执行未定义数量的 funcA() 和 funcB()?

javascript - 根据不同的值对 Google DataTable 进行透视

mysql - 从温度和 ID 数据库创建 Google Charts API 数据表

javascript - 从 AJAX/PHP 获取响应

javascript - 对象没有方法设置 jwplayer

javascript - 使用ajax加载html并委托(delegate)成功运行