Skip to content

fix: Show x values in data order when grouping enabled#320

Open
nekketsuuu wants to merge 1 commit intobdash-app:masterfrom
nekketsuuu:nekketsuuu-grouping
Open

fix: Show x values in data order when grouping enabled#320
nekketsuuu wants to merge 1 commit intobdash-app:masterfrom
nekketsuuu:nekketsuuu-grouping

Conversation

@nekketsuuu
Copy link

@nekketsuuu nekketsuuu commented Mar 3, 2026

If the following conditions are met:

  • Grouping is enabled,
  • Values of x axis are not sorted by Plotly, and
  • Some y value of some group is missing on some x value,

then the order of x values is broken because missing values are processed afterward.

This patch completely rewrote the way to pack values with grouping, and fixed the problem above by filling the missing values with null.

Screenshots

Details

An example query:

select '2026/01/01' as sold_date, 'A' as item_name, 100 as sold_count
union all
select '2026/01/01', 'B', 200
union all
select '2026/01/02', 'B', 100
union all
select '2026/01/03', 'A', 200
union all
select '2026/01/03', 'B', 300

Without Grouping

Charts are not changed with this patch.

Before After
スクリーンショット 2026-03-03 23 28 26 スクリーンショット 2026-03-03 23 27 36

With Grouping

Every chart type except for pie chart is broken with the conditions above. "2026/01/02" is not located between "2026/01/01" and "2026/01/03". Pie chart doesn't have the grouping option.

Type Before After
Bar スクリーンショット 2026-03-03 23 29 16 スクリーンショット 2026-03-03 23 24 20
Line スクリーンショット 2026-03-03 23 29 26 スクリーンショット 2026-03-03 23 25 34
Scatter スクリーンショット 2026-03-03 23 31 03 スクリーンショット 2026-03-03 23 26 24
Area スクリーンショット 2026-03-03 23 29 59 スクリーンショット 2026-03-03 23 26 37
Pie スクリーンショット 2026-03-03 23 35 51 スクリーンショット 2026-03-03 23 26 53

It seems that Plotly automatically sorts x values (so it hasn't been broken), for example, when they are formatted like "2026-01-01".

Grouping Before After
Disabled スクリーンショット 2026-03-03 23 39 36 スクリーンショット 2026-03-03 23 40 43
Enabled スクリーンショット 2026-03-03 23 38 47 スクリーンショット 2026-03-03 23 40 58

If the following conditions are met:

- Grouping is enabled,
- Values of x axis are not sorted by Plotly, and
- Some y value of some group is missing on some x value,

then the order of x values is broken because missing values are processed afterward.

This patch completely rewrote the way to pack values with grouping, and fixed the problem above by filling the missing values with null.

Co-authored-by: Claude <noreply@anthropic.com>
nekketsuuu added a commit to nekketsuuu/bdash-server that referenced this pull request Mar 3, 2026
The same change as bdash-app/bdash#320.
The following is the same description of the pull request above.

----

If the following conditions are met:

- Grouping is enabled,
- Values of x axis are not sorted by Plotly, and
- Some y value of some group is missing on some x value,

then the order of x values is broken because missing values are processed afterward.

This patch completely rewrote the way to pack values with grouping, and fixed the problem above by filling the missing values with null.
nekketsuuu added a commit to nekketsuuu/bdash-server that referenced this pull request Mar 3, 2026
The same change as bdash-app/bdash#320.
The following is the same description of the pull request above.

----

If the following conditions are met:

- Grouping is enabled,
- Values of x axis are not sorted by Plotly, and
- Some y value of some group is missing on some x value,

then the order of x values is broken because missing values are processed afterward.

This patch completely rewrote the way to pack values with grouping, and fixed the problem above by filling the missing values with null.

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant