Skip to content

Add Stack property to BarChartDataset and LineChartDataset#31

Closed
berndlueneburg wants to merge 2 commits into
BlazorExpress:mainfrom
berndlueneburg:feature/dataset-stack
Closed

Add Stack property to BarChartDataset and LineChartDataset#31
berndlueneburg wants to merge 2 commits into
BlazorExpress:mainfrom
berndlueneburg:feature/dataset-stack

Conversation

@berndlueneburg
Copy link
Copy Markdown
Contributor

Summary

Implements the stack dataset property for BarChartDataset and
LineChartDataset — both files already carry a //stack placeholder.

stack is a standard Chart.js dataset option. On a stacked scale,
datasets sharing the same stack id are combined; datasets with
different ids render independently. This enables the documented
"Stacked Bar with Groups" chart, currently not expressible via the wrapper.

Changes

  • BarChartDataset: new string? Stack (replaces the //Stack placeholder)
  • LineChartDataset: new string? Stack (replaces the //stack placeholder)

Both follow the existing property pattern ([AddedVersion],
[DefaultValue(null)], [Description], [ParameterTypeName],
[JsonIgnore(WhenWritingNull)]). Purely additive — no behaviour change,
omitted from JSON when null.

[AddedVersion("1.2.3")] is a placeholder — happy to adjust to whatever
the next release version should be.

Added Stack property to BarChartDataset for dataset grouping.
Added Stack property to LineChartDataset for dataset grouping.
@gvreddy04
Copy link
Copy Markdown
Collaborator

@berndlueneburg

Thanks for the contribution and for taking the time to put this PR together.

We already configure stacked behavior from chart options, so there is no need to expose the same configuration again on both BarChartDataset and LineChartDataset. Since both implementations represent the same behavior, we prefer to keep this configured in one place through options rather than duplicating it at the dataset level.

For quick reference, this is already handled from BarChartOptions here:
https://github.com/BlazorExpress/BlazorExpress.ChartJS/blob/main/BlazorExpress.ChartJS/Models/ChartOptions/ChartOptions.cs#L252

There is also already a demo showing this approach here:
https://chartjs.blazorexpress.com/demos/bar-chart#stacked-bar-chart

stacked-bar-chart

The sample below shows how stacked charts are configured today:

barChartOptions.Scales.X.Stacked = true;
barChartOptions.Scales.Y.Stacked = true;

Because of that, we are not planning to add Stack here. Thanks again for the PR and for the effort.

@gvreddy04 gvreddy04 closed this May 21, 2026
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.

2 participants