0

I'm looking for your support in order to know how to plot multiple time-series in a line-chart from Echarts. I read the documentation but i couldn't find a proper way to do it. Let me explain it:

  1. I have this simple SQL query (Postgres)

SELECT DAY, CATEGORY, INDEX FROM schema.table t WHERE DATE >= 'start_time' and DATE < 'end_time' ORDER BY 1,2

The field CATEGORY has 5 unique values:

`category_1
category_2
category_3
category_4
category_5
`

DAY is a date field who takes dates from 'start_time" to "end_time" for each Category. INDEX is a numeric value.

Here is an example how the table looks like for three days (end_time - start_time):

(https://i.stack.imgur.com/ICkQZ.png)

So, as you can see it has 5 time-series. Here is a unique time-series for instance

(https://i.stack.imgur.com/KcOQH.png)

  1. So, i would like to plot these 5 time-series in a line-chart from Echarts library. Here is an example how should it looks like (it's done with another tool)

(https://i.stack.imgur.com/KvTOw.png)

  1. The Echart documentation recommend to use the Dataset component but I've been doing a lot of tests with no success! :(

'''

dataset: {
        dimensions:   // How should i define dimension?
        source:       // How should i define the source for the 5 categories?
}
    
series: [
{
          type: 'line', 
          encode: { x: 'day', y: 'index' } //How should i split index for each category?
}
]

'''

Could you please help with these items?:

  1. How should i define the Dataset component for the 5 categories (time-series)?
  2. How should i define "series" and "encode" for the 5 categories?

Thanks in advance!!

JoPinc
  • 31
  • 2

0 Answers0