feat(Chart): support custom data source label formmater parameter#574
feat(Chart): support custom data source label formmater parameter#574
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis PR enables customization of data label formatting in the Chart component by exposing a formatter parameter, refactors deepMerge to use the shared utility, and removes obsolete initialization boilerplate in Chart.razor.js. Class diagram for updated Chart options and formatter parameterclassDiagram
class ChartOption {
+appendData
+options
}
class Options {
+anchor
+align
+formatter
+showDataLabel
+chartDataLabelColor
+font
}
ChartOption --> Options
Options : formatter
Options : anchor
Options : align
Options : showDataLabel
Options : chartDataLabelColor
Options : font
Flow diagram for custom data label formatter usage in Chartflowchart TD
A["Chart receives options"] --> B["Check for custom formatter in options"]
B --> C["Set datalabels.formatter to custom formatter"]
C --> D["Render chart with formatted data labels"]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for custom data source label formatter parameters in the Chart component by replacing a hardcoded Math.round formatter with a configurable option passed from the component options.
- Replaces hardcoded
Math.roundformatter with configurableoption.options.formatter - Refactors code to use shared
deepMergeutility function from BootstrapBlazor - Updates package version to 9.0.1
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Chart.razor.js | Updates formatter to use configurable parameter and imports shared deepMerge utility |
| BootstrapBlazor.Chart.csproj | Increments version from 9.0.0 to 9.0.1 |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| anchor: option.options.anchor, | ||
| align: option.options.align, | ||
| formatter: Math.round, | ||
| formatter: option.options.formatter, |
There was a problem hiding this comment.
The formatter property is being assigned directly from option.options.formatter without any validation or fallback. If option.options.formatter is undefined or null, this could cause chart rendering issues. Consider providing a default formatter like option.options.formatter || Math.round to maintain backward compatibility.
| formatter: option.options.formatter, | |
| formatter: option.options.formatter || Math.round, |
Link issues
fixes #573
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Support custom data label formatter in charts and refactor deepMerge usage
New Features:
Bug Fixes:
Enhancements: