Table Chart¶
Table charts include grouped table charts and time series table charts.
Grouped Table Chart Data Structure Description¶
// The columns of the following demo data table are ['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 the grouped table chart are composed by merging 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 obtained from the tags object in each item of series data |
|
group_by[#] | str | ||
column_names | list | Required | Part of the table columns; should correspond to non-time field values in series data 's column_names; corresponding column values are taken from series[#].values |
column_names[#] | str | ||
series | list | Required | Data groups; the length indicates how many rows of data there are in the table |
series[#] | dict | A collection of data | |
series[#].tags | dict | Attribute values for the group_by table columns (mapping values corresponding to the group_by part of columns, also used as alias key mappings) |
|
series[#].columns | list | Required | Same as series[#].column_names ['time', ...] |
series[#].columns[#] | str | Source data field key; the first column must be the time field |
|
series[#].column_names | list | Required | Source data field keys; other than time , they are used as references for table columns |
series[#].column_names[#] | str | ||
series[#].values | list | Data groups; their lengths should match that of series[#].columns (in table charts, mapping values corresponding to columns referenced by column_names ) |
|
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 Description¶
// The columns of the following demo data table are ['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 from series[#].columns
.
- Field description:
Parameter | Type | Required | Description |
---|---|---|---|
series | list | Required | Data groups; the length indicates how many sets of data there are in the table |
series[#] | dict | A collection of data | |
series[#].columns | list | Required | Consists of time and column name , i.e., ['time', column name] |
series[#].columns[#] | str | ||
series[#].values | list | Two-dimensional array; each entry represents the value of the column at different time points; the array length affects the number of rows in the table | |
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]
],
}
]
}
]
}