Skip to content

feat(Chart): support custom data source label formmater parameter#574

Merged
ArgoZhang merged 3 commits intomasterfrom
chore-chart
Sep 23, 2025
Merged

feat(Chart): support custom data source label formmater parameter#574
ArgoZhang merged 3 commits intomasterfrom
chore-chart

Conversation

@ArgoZhang
Copy link
Copy Markdown
Member

@ArgoZhang ArgoZhang commented Sep 23, 2025

Link issues

fixes #573

Summary By Copilot

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Support custom data label formatter in charts and refactor deepMerge usage

New Features:

  • Allow passing a custom formatter for chart data labels

Bug Fixes:

  • Fix data label formatting issue by replacing the hardcoded Math.round formatter

Enhancements:

  • Import the deepMerge utility from the shared module and remove the local implementation
  • Remove the temporary BootstrapBlazor initialization code in Chart.razor.js

Copilot AI review requested due to automatic review settings September 23, 2025 02:33
@bb-auto bb-auto Bot added the enhancement New feature or request label Sep 23, 2025
@bb-auto bb-auto Bot added this to the v9.2.0 milestone Sep 23, 2025
@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Sep 23, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This 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 parameter

classDiagram
    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
Loading

Flow diagram for custom data label formatter usage in Chart

flowchart 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"]
Loading

File-Level Changes

Change Details Files
Support custom data source label formatter
  • Replaced hardcoded Math.round with option.options.formatter for data labels
  • Applied the formatter value to ChartDataLabels plugin configuration
src/components/BootstrapBlazor.Chart/Components/Chart/Chart.razor.js
Refactor deepMerge usage
  • Removed local deepMerge implementation
  • Imported deepMerge from BootstrapBlazor utility module
  • Updated option merging logic to use the imported deepMerge
src/components/BootstrapBlazor.Chart/Components/Chart/Chart.razor.js
Remove obsolete initialization boilerplate
  • Deleted WIP comments and redundant window.BootstrapBlazor global init block
src/components/BootstrapBlazor.Chart/Components/Chart/Chart.razor.js

Assessment against linked issues

Issue Objective Addressed Explanation
#573 Support a custom data source label formatter parameter in the Chart component.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.round formatter with configurable option.options.formatter
  • Refactors code to use shared deepMerge utility 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,
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
formatter: option.options.formatter,
formatter: option.options.formatter || Math.round,

Copilot uses AI. Check for mistakes.
@ArgoZhang ArgoZhang merged commit 99db0f5 into master Sep 23, 2025
1 of 2 checks passed
@ArgoZhang ArgoZhang deleted the chore-chart branch September 23, 2025 02:33
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(Chart): support custom data source label formmater parameter

2 participants