Skip to content

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

@klausb

Description

@klausb

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
    }
  ]
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    enThis issue is in Englishnew-featurependingWe are not sure about whether this is a bug/new feature.staleInactive for a long time. Will be closed in 7 days.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions