Skip to content

fix(chart): bar brush selection stats#261

Merged
fahimfaisaal merged 4 commits into
mainfrom
fix/bar-brush-selection-stats
Jul 23, 2026
Merged

fix(chart): bar brush selection stats#261
fahimfaisaal merged 4 commits into
mainfrom
fix/bar-brush-selection-stats

Conversation

@hfl0506

@hfl0506 hfl0506 commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Related Issue

Closes #252

Changes

  • Added rectangular, keep, and clear brush controls to supported 2D bar charts.

  • Added multi-region selection metrics: Regions, Total, Avg, and Count.

  • Aggregates directly from rendered series indices, correctly handling grouped multi-
    series and tuple-mode bars.

  • Ignores null/non-finite values and deduplicates overlapping selected points.

  • Clears brush regions and summary state when chart options change.

  • Positioned the non-interactive stats overlay below the ECharts toolbox.

  • Preserved optimized large-bar rendering at 2,000+ points; brushing is hidden where
    ECharts large mode cannot select reliably.

  • Added regression coverage for grouped bars, mixed/value tuples, multi-region
    aggregation, and the large-data threshold.

Test Result

# commands
task build:ui
task build:cli

./bin/vizb bar flights.csv -g year,month -p x,y -o flights.html
open flights.html
Screenshot 2026-07-21 at 11 35 47 PM Screenshot 2026-07-21 at 11 36 00 PM Screenshot 2026-07-21 at 11 36 10 PM

Summary by CodeRabbit

  • Bug Fixes

    • Improved chart builder selection based on the chart’s rendered data, helping ensure charts display with the correct configuration.
    • Corrected axis badge counts for value-based and grouped charts.
  • Tests

    • Added coverage for mixed chart data and multiple grouped chart types.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

builderForChart now prioritizes rendered chart data shapes and 3D mode when selecting builders, while chartAxisBadgeCount tests cover value category-series input and grouped charts across multiple statType values.

Changes

Chart builder selection

Layer / File(s) Summary
Shape-based builder inference and badge-count coverage
ui/src/lib/builders/index.ts, ui/src/lib/utils.test.ts
builderForChart checks rendered data fields and render3D.mode before using chart.statType; tests add value category-series and grouped-axis badge-count cases.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: fahimfaisaal

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately describes the chart brush-selection stats fix.
Linked Issues check ✅ Passed The changes target grouped and mixed bar aggregation and add regressions for the affected stats, matching the bug in #252.
Out of Scope Changes check ✅ Passed The PR stays focused on chart builder selection logic and related tests; no unrelated changes stand out.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@hfl0506 hfl0506 changed the title Fix/bar brush selection stats fix: bar brush selection stats Jul 22, 2026
@hfl0506 hfl0506 self-assigned this Jul 22, 2026
@hfl0506 hfl0506 added bug Something isn't working good first issue Good for newcomers ui ui-related tasks chart chart releated works labels Jul 22, 2026
@hfl0506 hfl0506 added this to the Release v0.17.0 milestone Jul 22, 2026
@hfl0506
hfl0506 marked this pull request as ready for review July 22, 2026 06:43
@hfl0506
hfl0506 requested a review from fahimfaisaal as a code owner July 22, 2026 06:44
@hfl0506 hfl0506 changed the title fix: bar brush selection stats fix(chart): bar brush selection stats Jul 22, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
ui/src/lib/brushSelection.test.ts (1)

4-28: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the remaining selection edge cases.

This only covers primitive grouped bars. Add cases for tuple/object values, null/non-finite values, and duplicate (seriesIndex, dataIndex) entries across overlapping regions so the required filtering and deduplication behavior cannot regress.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/src/lib/brushSelection.test.ts` around lines 4 - 28, Extend the
brushSelectionStats tests with cases covering tuple and object-valued bar data,
null and non-finite values, and duplicate (seriesIndex, dataIndex) selections
across overlapping regions. Assert that only valid selectable values contribute
and duplicate data points are counted once, while preserving the existing
grouped-bar aggregation expectations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@ui/src/lib/brushSelection.test.ts`:
- Around line 4-28: Extend the brushSelectionStats tests with cases covering
tuple and object-valued bar data, null and non-finite values, and duplicate
(seriesIndex, dataIndex) selections across overlapping regions. Assert that only
valid selectable values contribute and duplicate data points are counted once,
while preserving the existing grouped-bar aggregation expectations.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 6b7e3b1c-c800-4b1d-9eea-57a2581890b0

📥 Commits

Reviewing files that changed from the base of the PR and between 6d9b88f and 35c4ac0.

📒 Files selected for processing (6)
  • ui/src/components/ChartBar.vue
  • ui/src/components/ChartCard.vue
  • ui/src/composables/charts/useBarChartOptions.test.ts
  • ui/src/composables/charts/useBarChartOptions.ts
  • ui/src/lib/brushSelection.test.ts
  • ui/src/lib/brushSelection.ts

@fahimfaisaal

Copy link
Copy Markdown
Member

@hfl0506 lets only fix the series x count problem; don't introduce any brush selection. I was thinking of closing this issue, but you started working on it. my bad

@hfl0506

hfl0506 commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

@hfl0506 lets only fix the series x count problem; don't introduce any brush selection. I was thinking of closing this issue, but you started working on it. my bad

will do

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
ui/src/lib/builders/index.ts (1)

13-19: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add regression coverage for all new builder branches.

The added tests cover series and mixedTuples, but not valueTuples/valuePoints3D or either render3D.mode branch. Add focused cases so these paths cannot silently fall back to statType.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/src/lib/builders/index.ts` around lines 13 - 19, Add focused regression
tests for builderForChart covering valueTuples and valuePoints3D selecting
value, render3D.mode set to continuous selecting value, and render3D.mode set to
mixed selecting mixed. Assert each case returns the expected builder and cannot
fall through to statType.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@ui/src/lib/builders/index.ts`:
- Around line 13-19: Add focused regression tests for builderForChart covering
valueTuples and valuePoints3D selecting value, render3D.mode set to continuous
selecting value, and render3D.mode set to mixed selecting mixed. Assert each
case returns the expected builder and cannot fall through to statType.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: adbddd3a-e7c1-459f-b2e7-ff178da249ab

📥 Commits

Reviewing files that changed from the base of the PR and between 35c4ac0 and 84bfa08.

📒 Files selected for processing (2)
  • ui/src/lib/builders/index.ts
  • ui/src/lib/utils.test.ts

@hfl0506

hfl0506 commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

@hfl0506 lets only fix the series x count problem; don't introduce any brush selection. I was thinking of closing this issue, but you started working on it. my bad

Hi fahim, please take a look when you have time. Thanks

@fahimfaisaal
fahimfaisaal merged commit 03994d2 into main Jul 23, 2026
5 checks passed
@fahimfaisaal
fahimfaisaal deleted the fix/bar-brush-selection-stats branch July 23, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working chart chart releated works good first issue Good for newcomers ui ui-related tasks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug]: Brush region selection stats show Total/Avg/Count as 0

2 participants