Table Chart¶
Table charts include Grouped Table Charts and Time Series Table Charts.
Grouped Table Chart Data Structure¶
// The demo data below has table columns: ['host', 'host_ip', 'columnA', 'columnB']
{
group_by: ['host', 'host_ip'],
column_names: ['columnA', 'columnB'],
series: [
{
tags: {
host: 'host_1',
host_ip: '111.11.123.103',
},
values: [[null, 1,2]],
column_names: ['time', 'columnA', 'columnB'],
columns: ['time', 'columnA', 'columnB'],
},
{
tags: {
host: 'host_2',
host_ip: '111.11.123.101',
},
values: [[null, 3,4]],
column_names: ['time', 'columnA', 'columnB'],
columns: ['time', 'columnA', 'columnB'],
},
{
tags: {
host: 'host_3',
host_ip: '111.11.123.102',
},
values: [[null, 5,6]],
column_names: ['time', 'columnA', 'columnB'],
columns: ['time', 'columnA', 'columnB'],
},
{
tags: {
host: 'host_4',
host_ip: '111.11.123.106',
},
values: [[null, 7,8]],
column_names: ['time', 'columnA', 'columnB'],
columns: ['time', 'columnA', 'columnB'],
},
],
},
The column values of a grouped table chart are composed of group_by and column_names. group_by can be empty.
- Field description:
| Parameter | Type | Required | Description |
|---|---|---|---|
| group_by | list | Part of the table columns. The corresponding column values are taken from the tags object of each item in series data. |
|
| group_by[#] | str | ||
| column_names | list | required | Part of the table columns. Should correspond to non-time field values in the column_names of series data. The corresponding column values are taken from series[#].values. |
| column_names[#] | str | ||
| series | list | required | Data groups. The length indicates how many rows the table has. |
| series[#] | dict | A set of data. | |
| series[#].tags | dict | Values associated with the group_by table columns (corresponding to the mapping values of the group_by columns, also used as mapping for alias key values). |
|
| series[#].columns | list | required | Same as series[#].column_names['time', ...] |
| series[#].columns[#] | str | Data source field key. The first column value must be the time field. |
|
| series[#].column_names | list | required | Data source field keys. Except for time, others are used as table column references. |
| series[#].column_names[#] | str | ||
| series[#].values | list | Data groups. The length should match series[#].columns. (In a table chart, these correspond to the mapping values of the column_names columns.) |
|
| series[#].values[#] | list | Composed of [null, data value, ...] |
|
| series[#].values[#][#] | str |
External Function Response Structure Example¶
@DFF.API('function_name', category='dataPlatform.dataQueryFunc')
def whytest_topology_test():
data1_1 = 100
data1_2 = 101
data2_1 = 200
data2_2 = 201
now1 = int(time.time()) * 1000
now2 = int(time.time()) * 1000
#
return {
"content": [
{
"group_by": ['attrA'],
"columns": ["filedA","filedB"]
"column_names": ["filedA","filedB"]
"series": [
{
"tags": {"attrA":'value1'},
"columns": ["time", "filedA","filedB"],
"values": [
[now1, data1_1,data1_2],
[now2, data2_1,data2_2]
],
"total_hits": -1
}
]
}
]
}
Time Series Table Chart Data Structure¶
// The demo data below has table columns: ['fieldA', 'fieldB', 'fieldC', 'fieldD']
{
"query": {},
"series": [
{
"values": [
[1737365938763, 19],
[1737365938585, 20],
[1737365938874, 21],
[1737365939137, 22]
],
"columns": ["time", "fieldA"]
},
{
"values": [
[1737365938763, 30],
[1737365938585, 30.5],
[1737365938874, 31],
[1737365939137, 31.5]
],
"columns": ["time", "fieldB"]
},
{
"values": [
[1737365938763, 50],
[1737365938585, 50.5],
[1737365938874, 51],
[1737365939137, 51.5]
],
"columns": ["time", "fieldC"]
},
{
"values": [
[1737365938763, 60],
[1737365938585, 60.5],
[1737365938874, 61],
[1737365939137, 61.5]
],
"columns": ["time", "fieldD"]
}
]
}
The column values of a time series table chart are composed by deduplicating and merging the second column data of series[#].columns.
- Field description:
| Parameter | Type | Required | Description |
|---|---|---|---|
| series | list | required | Data groups. The length indicates how many data groups the table has. |
| series[#] | dict | A set of data. | |
| series[#].columns | list | required | Composed of time and column_name, i.e., ['time', column_name]. |
| series[#].columns[#] | str | ||
| series[#].values | list | A 2D array. Each data item represents the value of that column at a different time dimension. The array length affects the table rows. | |
| series[#].values[#] | list | [timestamp, data value] |
|
| series[#].values[#][#] | str |
External Function Response Structure Example¶
@DFF.API('function_name', category='dataPlatform.dataQueryFunc')
def whytest_topology_test():
data1_1 = 100
data1_2 = 101
data2_1 = 200
data2_2 = 201
data3_1 = 101
data3_2 = 202
now1 = int(time.time()) * 1000
now2 = int(time.time()) * 1000
now3 = int(time.time()) * 1000
#
return {
"content": [
{
"series": [
{
"columns": ["time", "filedA"],
"values": [
[now1, data1_1],
[now2, data2_1],
[now3, data3_1],
],
},
{
"columns": ["time", "filedB"],
"values": [
[now1, data1_2],
[now2, data2_2]
[now3, data3_2]
],
}
]
}
]
}