I would like to draw a multi-line chart with legend from a query with format
like the following:
"aggregations": {
"time_buckets": {
"buckets": [
{
"key_as_string": "2022-02-22T00:00:00.000Z",
"key": 1645488000000,
"doc_count": 18478,
"count": {
"doc_count": 25570,
"categories_count": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 3,
"doc_count": 4218
},
{
"key": 1,
"doc_count": 3398
},
{
"key": 5,
"doc_count": 2218
},
{
"key": 0,
"doc_count": 38
}
]
}
}
},
I would like to draw the chart with x-axis to be time and y axis to be line chart of doc_count based on each key value of inner buckets with the legend to be the value of the key. Any help will be appreciated.
Note that the aggregated value might be missing for some buckets so need to handle when the key is missing in one time buckets (set the key count to 0). But you may assume only the key can be {0,1,2,3,4,5,6,7}