Skip to content

ref(dashboards): Improve categorical series types and structure#107631

Merged
gggritso merged 1 commit intomasterfrom
georgegritsouk/dain-1181-improve-typing-and-structure-for
Feb 5, 2026
Merged

ref(dashboards): Improve categorical series types and structure#107631
gggritso merged 1 commit intomasterfrom
georgegritsouk/dain-1181-improve-typing-and-structure-for

Conversation

@gggritso
Copy link
Member

@gggritso gggritso commented Feb 4, 2026

A few improvements to the types and code around categorical bar charts.

The main change is that I'm loosening the types around categorical data itself. Right now, the category can only be a string according to the types, but that's a bit too tight. Tabular data can return any kind of thing, and categorical data is just tabular data re-arranged. In this PR, I make it so that category and value are much looser, and corresponding to the incoming data rather than what can be plotted on the chart.

As a consequence of that, the type for what can actually be plotted is moved out to the categorical plottables, after all they decide what can be plotted! Handling for formatting these new looser category values as strings is moved into a formatting function.

This creates a pleasant symmetry between categorical and time series charts, now they have the same approach for how to handle different data types. It also makes converting between tabular data and categorical data simpler, which will come in handy soon.

The quirk is that ECharts needs all the categories to be strings even before formatting is applied, so we have to run X axis formatting on the data in Bars rather than in the X axis configuration. Alas!

Last important change is using the [category, value] format instead of {name: category, value: value} format in output of toSeries. The former is more robust and allows ECharts to correctly assign points to categories regardless of order. This is very important in cases where different plottables have different categories! Otherwise ECharts will silently put points on the wrong categories which is ... catastrophically fucked up

Cursor Bugbot found 1 potential issue for commit acafc7a

@linear
Copy link

linear bot commented Feb 4, 2026

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Feb 4, 2026
@gggritso gggritso changed the title refactor(dashboards): Improve categorical series types and structure ref(dashboards): Improve categorical series types and structure Feb 4, 2026
@gggritso gggritso force-pushed the georgegritsouk/dain-1181-improve-typing-and-structure-for branch from f993c60 to 1fb4f67 Compare February 4, 2026 21:49
@gggritso gggritso force-pushed the georgegritsouk/dain-1181-improve-typing-and-structure-for branch from 1fb4f67 to 4cda324 Compare February 4, 2026 21:57
@gggritso gggritso force-pushed the georgegritsouk/dain-1181-improve-typing-and-structure-for branch from 4cda324 to 3a9bd26 Compare February 4, 2026 22:03
Improve the typing and structure of the categorical series infrastructure:

- Export AttributeValueType and use it as the base for CategoricalValueType
- Add CategoricalItemCategory, CategoricalItemValue, and Category types
- Add PlottableCategoricalValueType for constrained plottable types
- Move type coercion from data layer to plottable layer with fallback
- Add formatXAxisValue formatter for categorical chart X-axis labels
- Add transformTabularDataToCategoricalSeries utility for data transformation

These changes align the categorical series types with the TimeSeries pattern,
where the data layer accepts broad types and the plottable layer constrains
to renderable types.
@gggritso gggritso force-pushed the georgegritsouk/dain-1181-improve-typing-and-structure-for branch from 3a9bd26 to acafc7a Compare February 4, 2026 22:45
@gggritso gggritso requested a review from nsdeschenes February 4, 2026 22:55
@gggritso gggritso marked this pull request as ready for review February 4, 2026 22:55
@gggritso gggritso requested a review from a team as a code owner February 4, 2026 22:55
Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Copy link
Contributor

@nsdeschenes nsdeschenes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ECharts seems to be very ... particular 😭

@gggritso gggritso merged commit e24f573 into master Feb 5, 2026
64 checks passed
@gggritso gggritso deleted the georgegritsouk/dain-1181-improve-typing-and-structure-for branch February 5, 2026 14:29
jaydgoss pushed a commit that referenced this pull request Feb 12, 2026
)

A few improvements to the types and code around categorical bar charts.

The main change is that I'm loosening the types around categorical data
itself. Right now, the category can only be a string according to the
types, but that's a bit too tight. Tabular data can return any kind of
thing, and categorical data is just tabular data re-arranged. In this
PR, I make it so that category and value are much looser, and
corresponding to the incoming data rather than what can be plotted on
the chart.

As a consequence of that, the type for what can actually be plotted is
moved out to the categorical plottables, after all they decide what can
be plotted! Handling for formatting these new looser category values as
strings is moved into a formatting function.

This creates a pleasant symmetry between categorical and time series
charts, now they have the same approach for how to handle different data
types. It also makes converting between tabular data and categorical
data simpler, which will come in handy soon.

The quirk is that ECharts needs all the categories to be strings even
before formatting is applied, so we have to run X axis formatting on the
data in `Bars` rather than in the X axis configuration. Alas!

Last important change is using the `[category, value]` format instead of
`{name: category, value: value}` format in output of `toSeries`. The
former is more robust and allows ECharts to correctly assign points to
categories regardless of order. This is _very_ important in cases where
different plottables have different categories! Otherwise ECharts will
silently put points on the wrong categories which is ...
catastrophically fucked up

<!-- BUGBOT_STATUS --><sup><a
href="https://cursor.com/dashboard?tab=bugbot">Cursor Bugbot</a> found 1
potential issue for commit <u>acafc7a</u></sup><!-- /BUGBOT_STATUS -->
dcramer pushed a commit that referenced this pull request Feb 17, 2026
)

A few improvements to the types and code around categorical bar charts.

The main change is that I'm loosening the types around categorical data
itself. Right now, the category can only be a string according to the
types, but that's a bit too tight. Tabular data can return any kind of
thing, and categorical data is just tabular data re-arranged. In this
PR, I make it so that category and value are much looser, and
corresponding to the incoming data rather than what can be plotted on
the chart.

As a consequence of that, the type for what can actually be plotted is
moved out to the categorical plottables, after all they decide what can
be plotted! Handling for formatting these new looser category values as
strings is moved into a formatting function.

This creates a pleasant symmetry between categorical and time series
charts, now they have the same approach for how to handle different data
types. It also makes converting between tabular data and categorical
data simpler, which will come in handy soon.

The quirk is that ECharts needs all the categories to be strings even
before formatting is applied, so we have to run X axis formatting on the
data in `Bars` rather than in the X axis configuration. Alas!

Last important change is using the `[category, value]` format instead of
`{name: category, value: value}` format in output of `toSeries`. The
former is more robust and allows ECharts to correctly assign points to
categories regardless of order. This is _very_ important in cases where
different plottables have different categories! Otherwise ECharts will
silently put points on the wrong categories which is ...
catastrophically fucked up

<!-- BUGBOT_STATUS --><sup><a
href="https://cursor.com/dashboard?tab=bugbot">Cursor Bugbot</a> found 1
potential issue for commit <u>acafc7a</u></sup><!-- /BUGBOT_STATUS -->
@github-actions github-actions bot locked and limited conversation to collaborators Feb 21, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants