fix: render boxPlot outliers after updateDataSync from empty data - #4695
dyk1454683243-sudo wants to merge 2 commits into
Conversation
…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
left a comment
There was a problem hiding this comment.
@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']; |
There was a problem hiding this comment.
[P2] 请用有效 spec 复现字段缺失,避免手动构造内部状态作为修复依据
这里手动将 _fieldY 设为不含 y6,但真实 BoxPlotChartSpecTransformer._getDefaultSeriesSpec() 会把 outliersField 放入对应的数据轴字段,且这一过程不依赖初始 data 是否为空;CartesianSeries.getStatisticFields() 也根据配置字段和轴 helper 生成统计项,而不是根据初始数据的键生成。因此这个用例绕开了 #4270 的实际初始化路径。撤回本 PR 的生产代码改动后,原 issue 的浏览器复现以及纵向、横向、清空再填充的真实 VChart 用例仍然通过,只有这里和手动清空 axis helpers 的用例失败。请改为通过有效 spec / 公共 API 触发、基线失败而 PR 通过的回归测试,再据此决定是否需要新增统计字段兜底。
Fixes #4270
🤔 This is a ...
🔗 Related issue link
Fixes #4270
🔗 Related PR link
Separate from #4693 / #4694. Branched from current upstream
develop.💡 Background and solution
Constructing a
boxPlotwith empty data plusoutliersField, then filling viaupdateDataSync, did not render outlier points from the array field (they do render when the same data is present at init).getStatisticFields()only rewrote operations whenoutliersFieldwas already present insuper.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
outliersFieldwitharray-min/array-maxwhen the spec sets it (update if present, push if missing).foldOutlierDataandviewDataUpdate→_outlierData.updateData()are unchanged.📝 Changelog
outliersFieldstatistics soupdateDataSyncfrom empty data still renders outlier pointsoutliersField注册 array-min/array-max 统计,使updateDataSync后异常点能正常渲染☑️ Self-Check before Merge
Tests
getStatisticFields()adds or rewrites theoutliersFieldentry with['array-min', 'array-max']when the key is missing or present, and does nothing whenoutliersFieldis unset.values+outliersField: 'y6'→updateData('boxPlot', y6 array rows)produces folded outlier rows[12.01, 12.02, 14.03]andy6min/max statistics.outliersFieldstill folds those rows.foldOutlierDatastill expands each numeric value in an outliers array.data: [{ id: 'boxPlot' }]+updateDataSync) assert outlier graphics; they skip under the node runner and run under packagejest-electron(CI macos-latest).Verification
eslint --quietonpackages/vchart/src/series/box-plot/box-plot.tsand the two tests: cleanprettier --checkon the same files: cleanjest __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)jest-electronrunner hung in this Linux environment (CI uses macos-latest); the node runner covers the statistic-field contract and empty-init fold/update path