Skip to content

fix: render boxPlot outliers after updateDataSync from empty data - #4695

Open
dyk1454683243-sudo wants to merge 2 commits into
VisActor:developfrom
dyk1454683243-sudo:cursor/fix-boxplot-outliers-updatedatasync-4270-b8e8
Open

dyk1454683243-sudo wants to merge 2 commits into
VisActor:developfrom
dyk1454683243-sudo:cursor/fix-boxplot-outliers-updatedatasync-4270-b8e8

Conversation

@dyk1454683243-sudo

@dyk1454683243-sudo dyk1454683243-sudo commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #4270

🤔 This is a ...

  • Bug fix
  • Test Case

🔗 Related issue link

Fixes #4270

🔗 Related PR link

Separate from #4693 / #4694. Branched from current upstream develop.

💡 Background and solution

Constructing a boxPlot with empty data plus outliersField, then filling via updateDataSync, did not render outlier points from the array field (they do render when the same data is present at init).

getStatisticFields() only rewrote operations when outliersField was already present in super.getStatisticFields(). Empty initial data (or an unbound value axis) can omit that key, so the field never received ['array-min', 'array-max'].

This change always registers outliersField with array-min / array-max when the spec sets it (update if present, push if missing). foldOutlierData and viewDataUpdate_outlierData.updateData() are unchanged.

📝 Changelog

Language Changelog
🇺🇸 English fix: register boxPlot outliersField statistics so updateDataSync from empty data still renders outlier points
🇨🇳 Chinese 修复:空初始数据时仍为 outliersField 注册 array-min/array-max 统计,使 updateDataSync 后异常点能正常渲染

☑️ Self-Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

Tests

  • getStatisticFields() adds or rewrites the outliersField entry with ['array-min', 'array-max'] when the key is missing or present, and does nothing when outliersField is unset.
  • Chart repro: empty values + outliersField: 'y6'updateData('boxPlot', y6 array rows) produces folded outlier rows [12.01, 12.02, 14.03] and y6 min/max statistics.
  • Non-empty init with the same outliersField still folds those rows.
  • foldOutlierData still expands each numeric value in an outliers array.
  • VChart render cases (issue-shaped data: [{ id: 'boxPlot' }] + updateDataSync) assert outlier graphics; they skip under the node runner and run under package jest-electron (CI macos-latest).

Verification

  • eslint --quiet on packages/vchart/src/series/box-plot/box-plot.ts and the two tests: clean
  • prettier --check on the same files: clean
  • jest __tests__/unit/series/box-plot-outliers.test.ts __tests__/unit/data/box-plot-transform-options.test.ts --runner=jest-runner --testEnvironment=node: 8 passed, 2 skipped (VChart graphics)
  • Package jest-electron runner hung in this Linux environment (CI uses macos-latest); the node runner covers the statistic-field contract and empty-init fold/update path

…ataSync

Register array-min/array-max for outliersField even when empty initial data omits that key, so updateDataSync can render outlier points.

Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>
Add the issue-shaped VChart render cases and keep the node-runner unit coverage for empty-init updateData plus foldOutlierData.

Co-authored-by: David <dyk1454683243-sudo@users.noreply.github.com>

@xile611 xile611 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@dyk1454683243-sudo 已完成 review,目前建议先补充真实回归证据,再以修复 #4270 合并。

对比基线 c4191139a340f18f0e32dcb353c51009d88a6205 和本 PR 的 5227b8caababa2f6ef1f8d224bceb053ad27a159,直接使用 #4270 的 spec(初始 data: [{ id: 'boxPlot' }],renderSync 后 updateDataSync),浏览器中两者都能正确显示三个离群点,离群值统计均为 min=12.01、max=14.03,轴域均为 [0, 15]。因此当前基线已无法复现 issue,尚未证明本次统计字段兜底是必要修复。

验证情况:

  • 本地补充的真实 VChart 场景:纵向、横向、清空后再次填充,基线和 PR 均通过。
  • 合并运行上述用例和 PR 新增测试,PR 为 11 passed / 2 skipped(node 环境跳过两个 DOM 渲染用例,另做了实际浏览器验证);仅撤回生产代码改动后为 9 passed / 2 failed / 2 skipped。失败的两个用例分别手动移除了内部字段和清空 axis helpers,不能证明 issue 的公共 API 路径存在该问题。
  • 修改文件的 ESLint、Prettier 检查通过;未发现新增渲染回归。

请补充一个通过有效 spec / 公共 API 能在基线失败、在本 PR 通过的回归用例,并据此定位根因。如果找不到该场景,建议移除缺乏复现依据的生产代码兜底,保留有效的回归测试,并调整 PR 的修复声明。具体测试问题见行内意见。

);
(series as any)._outliersField = 'y6';
(series as any)._fieldX = ['x'];
(series as any)._fieldY = ['y5', 'y3', 'y2', 'y4', 'y1'];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] 请用有效 spec 复现字段缺失,避免手动构造内部状态作为修复依据

这里手动将 _fieldY 设为不含 y6,但真实 BoxPlotChartSpecTransformer._getDefaultSeriesSpec() 会把 outliersField 放入对应的数据轴字段,且这一过程不依赖初始 data 是否为空;CartesianSeries.getStatisticFields() 也根据配置字段和轴 helper 生成统计项,而不是根据初始数据的键生成。因此这个用例绕开了 #4270 的实际初始化路径。撤回本 PR 的生产代码改动后,原 issue 的浏览器复现以及纵向、横向、清空再填充的真实 VChart 用例仍然通过,只有这里和手动清空 axis helpers 的用例失败。请改为通过有效 spec / 公共 API 触发、基线失败而 PR 通过的回归测试,再据此决定是否需要新增统计字段兜底。

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] boxPlot outliersField not work

3 participants