Repository navigation
Conversation
The semantic layer covers the common cases; ECharts is larger than any channel set. Until now a chart needing a second value axis, a mixed mark type, markLine/dataZoom, a formatter, or per-series styling had to leave Flint and hand-write the option — losing the layer it came for. chart_spec.echarts patches the compiled option, applied last so it wins over the layout pass: - objects merge recursively; arrays of plain objects (series, xAxis, yAxis) merge element-wise by index, appending past the end, so series[1] is addressable without restating series[0]; other arrays replace; an empty array says nothing; "_" keys are dropped with a warning. - series entries may bind columns instead of carrying data: field / fields add series read from the chart's rows (categoryField picks the pairing column, defaulting to the chart's x field), and axis: "right" puts one on a right-hand value axis that Flint creates when missing. Bound entries are added, unbound entries patch by index. - backend-scoped: the other assemblers ignore the key, as Vega-Lite ignores theme_spec. The MCP tool declares it too: chart_spec there is a zod object, which strips unknown keys, so without the declaration a native patch never reached the assembler. Verified: 18 new flint-chart unit tests pinning the merge contract; 3 flint-mcp tests rendering a column-bound dual-axis chart end to end (SSR → SVG) plus a compile_chart passthrough case; full flint-chart 1671 + flint-mcp 90 tests, typecheck, lint, build and site:build clean; a real PNG rendered from a spec that binds a second metric to a right axis. Guide: docs/native-echarts-options.md (+ zh-CN).
Author
|
@microsoft-github-policy-service agree |
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.
What
chart_spec.echarts— a native ECharts option patch that is merged onto the compiled option, plus column binding for series added through it.This closes the gap where a chart needs something the semantic layer does not model. A second value axis, a bar and a line in one chart,
markLine/markArea,dataZoom, axis or tooltip formatters, per-seriesareaStyle, customgrids — today a caller who needs one of those has to leave Flint and hand-write the option, losing the layer they came for.{ "chartType": "Line Chart", "encodings": { "x": { "field": "month" }, "y": { "field": "revenue" } }, "echarts": { "legend": { "show": true, "top": 6 }, "yAxis": [{ "name": "Revenue" }, { "name": "Margin", "position": "right" }], "series": [ { "name": "Revenue", "lineStyle": { "width": 2 } }, { "type": "line", "field": "margin", "name": "Margin rate", "axis": "right" } ] } }Applied last, so it is authoritative over what Flint decided above it: objects merge recursively, arrays of plain objects (
series,xAxis,yAxis) merge element-wise by index with entries past the end appended, any other array replaces, and_-prefixed keys are dropped with aninfowarning. A series entry that binds a column is added (andaxis: "right"puts it on a right-hand value axis that Flint creates if missing); one that does not patches the series at its own index. Backend-scoped: the other assemblers ignore the key, as Vega-Lite ignorestheme_spec. No template change and no new channel.Guide:
docs/native-echarts-options.md(+zh-CN);docs/api-reference.mdand the CHANGELOG updated. The MCP tool input schema declares the field too, since zod drops unknown keys inchart_spec.Verified: 18 new flint-chart tests pinning the merge contract, 3 flint-mcp tests rendering a column-bound dual-axis chart end to end, plus a
compile_chartpassthrough case;typecheck,lint,test,buildandsite:buildall clean.