echarts icon indicating copy to clipboard operation
echarts copied to clipboard

[Feature] Dynamic generation of series based on encoding/partitioning

Open klausb opened this issue 3 years ago • 1 comments

What problem does this feature solve?

From the tutorial I can follow the process of encoding a single dataset into multiple series. However the number of resulting series is fixed and baked into the chart config. In my use case, I need a partitioning of the original data by the distinct values of a dimension. For example the dataset consists of three columns: time, value and city. Now I do a grouping/partitioning on city and expect a time-series line chart per city. If I know all cities upfront, I can set up an encoding and a series per city, but normally you don't know and with changing data, the resulting number of series is changing.

What does the proposed API look like?

The idea would be to provide something like a 'groupBy' property in a series config to indicate that a series should be rendered per each distinct value of the dimension mentioned in the groupBy property.

For the example below it would be like this:

option = {
  dataset: {
    source: [
      // t1, t2, ... are meant to be real timestamp values
      ['time', 'city', 'value'],
      ['t1', 'Rome', 93.7],
      ['t2', 'NY', 55.1],
      ['t3', 'L.A.', 82.5]
      ['t4', 'Rome', 83.7],
      ['t5', 'NY', 59.1],
      ['t6', 'L.A.', 22.5]
    ]
  },
  xAxis: { type: 'time' },
  yAxis: {},
  series: [
    { 
      type: 'line',
      groupBy: ['city']  // this leads to 3 lines
    }
  ]
};

klausb avatar Dec 22 '22 09:12 klausb

This issue has been automatically marked as stale because it did not have recent activity. It will be closed in 7 days if no further activity occurs. If you wish not to mark it as stale, please leave a comment in this issue.

github-actions[bot] avatar Dec 21 '24 21:12 github-actions[bot]

This issue has been automatically closed because it did not have recent activity. If this remains to be a problem with the latest version of Apache ECharts, please open a new issue and link this to it. Thanks!

github-actions[bot] avatar Dec 29 '24 21:12 github-actions[bot]