feat(plugin-dashboard): forward the chartConfig presentation keys the chart block delivers - #3934
Merged
Merged
Conversation
… chart block delivers `DashboardWidgetSchema.chartConfig` is declared as the full spec `ChartConfigSchema`, but the ADR-0021 dataset path lowered exactly one key onto the chart renderer — `showLegend` (#3135). `title`, `subtitle`, `description`, `height`, `colors`, `showDataLabels`, `annotations` and `interaction` parsed as valid metadata, reached DatasetWidget, and were dropped before the chart schema was built, even though the underlying chart block draws every one of them. DatasetWidget now lowers them, on two mechanical criteria that both have to hold: the chart block draws the key end to end on this path (each is pinned at the DOM level, so nothing is forwarded to a prop that ignores it), and the key does not fight the dataset derivation. `xAxis`/`yAxis`/`series` therefore stay out (derived from the dataset selection; an authored one would shadow the derived binding), `type` stays out (the widget's own type picks the family via CHART_TYPE_MAP), and `aria` stays out because nothing on this path reads it — AdvancedChartImpl has no `aria` prop and SchemaRenderer's ARIA injection reads the flat ariaLabel/ariaDescribedBy/role. `colors` is split the way the react tier splits it: a string[] is the positional palette, a {value: color} record is a per-category map merged over the category dimension's own option colours. Part of objectstack-ai/objectstack#5175 Fixes objectstack-ai/objectstack#7016 Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
Collaborator
Author
|
✅ 验收通过(objectui 分片 PM,session 实物核验:base 验收要点:
Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of objectstack-ai/objectstack#5175
Fixes objectstack-ai/objectstack#7016
背景
DashboardWidgetSchema.chartConfig声明的是完整的 specChartConfigSchema(14 个键),但 ADR-0021 dataset 路径只把其中一个键落到渲染器上 ——showLegend(objectui#3135)。其余的键(title/subtitle/description/height/colors/showDataLabels/annotations/interaction)解析为合法元数据、抵达DatasetWidget、在构造 chart schema 之前被丢掉。底层 chart 块本身全都兑现这些键 —— 惰性纯粹出在 dashboard 这一次转发上。行号漂移如实报告:issue 正文基于 @91757a7 写的
:595-605/:632,在本 PR 的 base(c2fd1223a)上实际是DatasetWidget.tsx:987-997(取键)与:1024(构造 schema)。转发判据(两条同时满足才转发)
{ type: 'chart' }经 ComponentRegistry 解析到ChartRenderer→AdvancedChartImpl。每一个转发键都有 DOM 级实测钉,⛔ 绝不转发到一个会忽略它的 prop(那只是把 declared 不等于 enforced 下沉一层)。xAxis/yAxis/series由 dataset selection 推导(buildChartSeries),作者写的会遮蔽推导出的绑定并把图画白,一律不转发。逐键判定表
showLegendDatasetWidget.showLegend.test.tsx原有钉不动titleAdvancedChartImpl.tsx:233-241ChartFrame绘制;实测:dashboard 元数据写title后 DOM 出现该文本,且 chart 容器不再是 widget 根的直接子节点(frame 包了一层)subtitleChartFrame的第二行;实测同一条测试descriptionAdvancedChartImpl.tsx:299→ 容器role="img"+aria-label;实测:[data-slot="chart"]的role为img、aria-label为写入值;未声明时两者都为 null(不给无名图形盖role="img")heightAdvancedChartImpl.tsx:296-298→ 容器内联style.height;实测:写height: 420后style.height === '420px',未声明时为空且保留h-[350px]默认类colors(string[])colorsAdvancedChartImpl.tsx:430-432getPalette();实测:pie 的path.recharts-sectorfill 依次等于调色板colors({value: color})categoryColorsChartRenderer透传categoryColors,渲染层按分类优先查表;实测:sector fill 取作者 map 的色而非调色板色。两臂经不同 prop 到达渲染器,拆分与 react tier 的ObjectChart.tsx:769-782完全一致,作者 map 合并在维度选项色之上(spec 字段注释规定的优先级)showDataLabelsAdvancedChartImpl.tsx:580-584LabelList;实测:.recharts-label-list text依次为120/80;关掉或未声明时为空数组(负向断言前先 await 出图,避免"因为什么都没画所以绿")annotationsAdvancedChartImpl.tsx:530-568ReferenceLine/ReferenceArea;实测:line标注画出.recharts-reference-line且Target标签可见,region标注画出.recharts-reference-area;空数组不下发死键interactionAdvancedChartImpl.tsx:570-578,tooltips/brush两个键都被读;实测:brush: true画出.recharts-brush,tooltips: false让.recharts-tooltip-wrapper从有到无(带"开"的对照臂)typechartType通道(CHART_TYPE_MAP,DatasetWidget.tsx:944)。负向钉:piewidget 写chartConfig.type: 'line',chartType仍是pie,specType不出现xAxis/yAxisxAxis/yAxis,xAxisKey仍是推导出的维度seriesbuildChartSeries推导。负向钉:写series: [{ name: …, stack: 'g' }]后 schema 的series仍是推导出的dataKey形状、stack不出现ariaAdvancedChartImpl没有ariaprop,SchemaRenderer的 ARIA 注入读的是扁平的ariaLabel/ariaDescribedBy/role(packages/react/src/SchemaRenderer.tsx:107-118),不读嵌套aria对象。实测双向钉:直接把aria交给ChartRenderer也不改任何属性;dashboard 侧写了同样一个属性都不出现。见下收窄候选清单(交回 #5175 的收窄半边)
aria——ChartConfigSchema声明、chart 路径上无人读。存在一个"把aria.ariaLabel摊平成ariaLabel让 SchemaRenderer 读到"的翻译写法,本 PR 故意不做:(a) react tier 的ObjectChart不做这个翻译,dashboard 单独做会造出一个只此一处的方言;(b)description已经在 chart 容器上占了可访问名(role="img"+aria-label),摊平后的ariaLabel会落在 SchemaRenderer 的外层包裹元素上,产生两个嵌套的可访问名 —— 那是 a11y 缺陷不是能力;(c)AriaProps.role在 chart 上无处安放。到底是给它一个读者还是从ChartConfigSchema收窄掉,是契约裁决,归 #5175。xAxis/yAxis/series—— 在一个推导这三者的 surface 上被声明。本 PR 把"写了仍被忽略"钉成现状契约,不代表它应该长期这样声明。测试
packages/plugin-dashboard/src/__tests__/DatasetWidget.chartConfig.test.tsx—— 判定表本身,在 schema 接缝上(stub 掉SchemaRenderer,与.showLegend/.animation同一个缝)。正向:每个转发键;负向:xAxis/yAxis/series/type/aria写了仍被忽略;边界:height: 0/ 负数被丢、空annotations不下发、未声明chartConfig时十个键一个都不出现。packages/plugin-dashboard/src/__tests__/DatasetWidget.chartConfig.dom.test.tsx—— 真链路端到端 DOM,不 stub 任何渲染器:DatasetWidget→SchemaRenderer→ registry 的chart→AdvancedChartImpl。覆盖在 RechartsResponsiveContainer之外绘制的键(标题 / 副标题 / 可访问名 / 高度)。packages/plugin-charts/src/ChartRenderer.dashboardChartConfig.test.tsx—— plot 内部那一半。marks(bar / LabelList / ReferenceLine / Brush)需要一个被测量到的盒子,ResponsiveContainer在 headless DOM 里报 0x0、不渲染子节点;而recharts只在 plugin-charts 里解析得到,所以把它 mock 成固定尺寸的那半证据只能落在这个包。测试驱动的是ChartRenderer(registry 对type: 'chart'解析到的那个组件),schema 与DatasetWidget实际下发的形状逐字节一致。为什么拆两处而不是一处:在 dashboard 那个 harness 里断言"没有 brush / 没有 reference line"会因为什么都没画而通过 —— 那是假绿。所以 plot 内部的键一律在能真的画出来的地方钉,dashboard 侧只钉容器外确实渲染的元素(
aria的负向钉留在 dashboard 侧是成立的:两个可能承载可访问名的元素 —— chart 容器与 SchemaRenderer 包裹层 —— 都在ResponsiveContainer之外,都确实渲染)。命令与结果
反向验证(方向先判后跑)
先判的方向:把转发那段还原成 base 的 showLegend-only 实现后,正向钉全红、拒收钉全绿(它们断言的是"键不出现",老代码同样满足),plugin-charts 那个文件整体全绿(它直接驱动
ChartRenderer,根本不经过DatasetWidget)。实跑与预判一致:
红的 9 条正是 9 条正向钉;拒收钉与
showLegend(那是 #3135 的,不是本 PR 的)照常绿。changeset
.changeset/dataset-widget-chartconfig-presentation-os7016.md,@object-ui/plugin-dashboard: patch,写明「dashboard 元数据的 chartConfig 呈现键首次生效」以及行为开启面:存量 dashboard 写过这些键的,从无效变有效 —— 写过chartConfig.title的会在图内多出一行标题(widget 卡片自己的title是另一个键),写过height的不再填满卡片,写过colors的不再用主题调色板,showDataLabels/annotations/interaction.brush开始绘制。没写chartConfig、或只写了showLegend的 widget 渲染与之前逐字节一致(未声明的键一律不下发,渲染器自己的默认值继续说话)。附带说明
packages/plugin-dashboard/package.json加了一条 devDependency@object-ui/plugin-charts(workspace):端到端 DOM 测试需要它的注册副作用,声明出来而不是靠 vitest alias 隐式解析。无环 —— plugin-charts 不依赖 plugin-dashboard。packages/spec(收窄半边归 spec 车道),⛔ 未碰DashboardRenderer的内联路径。Generated by Claude Code