[Lens as code] preserve all chart style properties during API format round-trip#253597
[Lens as code] preserve all chart style properties during API format round-trip#253597
Conversation
…rip (#253049) When `lens.apiFormat` is enabled, metric chart style properties (primaryPosition, titleWeight, secondaryAlign) were silently dropped during the Lens state to API format conversion. This caused style changes made via the metric chart Style panel to be lost on dashboard save/reload. Add `position`, `title_weight` to the primary metric API schema and `alignments` to the secondary metric API schema, then wire them through both transform directions so these values survive the round-trip. Closes #253049 Co-authored-by: Cursor <cursoragent@cursor.com>
|
/ci |
…d-trip Extends the metric chart fix to cover all remaining chart types where visualization state properties were silently dropped during the Lens state <-> API format round-trip conversion when lens.apiFormat is enabled. Properties added across 5 chart types + 1 shared concern: - XY: reference line iconPosition - Partition: legendPosition, legendStats (pie/treemap/mosaic/waffle) - Datatable: showRowNumbers - Heatmap: shouldTruncate, strokeWidth, strokeColor, percentageMode, showTooltip, highlightInHover, ariaLabel - Gauge: respectRanges, commonLabel, ariaLabel - Shared coloring: palette continuity Co-authored-by: Cursor <cursoragent@cursor.com>
|
To fix the code scanning warnings you need to add checks like here to the schemas: #253411 |
Address code scanning warnings for unbounded schema.arrayOf() calls in pie, treemap, and mosaic legend values schemas. Co-authored-by: Cursor <cursoragent@cursor.com>
|
/ci |
| @@ -37,6 +37,7 @@ function getLegendProps(legend: HeatmapVisualizationState['legend']): HeatmapSta | |||
| ...stripUndefined<HeatmapState['legend']>({ | |||
There was a problem hiding this comment.
config_builder correctly round-trips the angled orientation value. there is a separate "angled axis labels don't work in heatmap" is a rendering issue in the heatmap visualization expression itself — it receives the -45 rotation value but doesn't render it at an angle. That's a separate bug from this PR's scope #211214 (which is about values being lost during the API format round-trip).
- Rename icon_position to decoration_position and limit to auto|left|right - Remove aria_label from heatmap API schema and transforms - Remove legendStats from treemap mock (not exposed in UI) - Extract buildShowRowNumbers helper in datatable appearance - Fix reference line mock to use valid icon position value Co-authored-by: Cursor <cursoragent@cursor.com>
|
/ci |
|
Pinging @elastic/kibana-visualizations (Team:Visualizations) |
|
/ci |
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
History
|
There was a problem hiding this comment.
Thank you Graham for your attempt, but as proved by multiple review comments, allucinations, context missing and no overall schema design process in the generation creates a lot more work on our side as reviewer then for some engineer to pick this task from the beginning and work on that.
I get your willingness to supporting us, but this create way more problems than the the benefits.
I believe is way more useful if, instead of asking LLM to fix these things, you ask LLM to help you idenfity properly every missing parameters, providing a good and validated list of what is missing, from where, what are the parameters available etc. This will help way more then a generated code. The important aspect is the manual Validation: as seen in the review comments, some parameters are just made up, so a manual validation on the interface is greatly appreciated and valuated more then an unsupervised LLM trying its own findings.
We also follows some guidelines on how to correctly reply to PR reviews that creates a structured but simplified process, that in this PR is not followed (if you want I can share the docs on slack as it is not public)
Pull request was closed

Summary
Closes #253049
When
lens.apiFormatis enabled, visualization style properties are silently dropped during the Lens state <-> API format round-trip conversion on save/load. This causes style changes made in the UI to revert to defaults after saving and reloading a dashboard.Root cause: The API format schemas for multiple chart types did not include fields for certain visualization state properties. During the
enrichConfigurationWithVisualizationProperties(Lens -> API) step they were not written, and duringbuildVisualizationState(API -> Lens) they were not read back, so they defaulted.Properties fixed
primaryPosition,titleWeight,secondaryAligndecoration_position(renamed fromicon_position)legendPositionshowRowNumbersshouldTruncate,strokeWidth,strokeColor,percentageMode,showTooltip,highlightInHoverrespectRanges,commonLabelcontinuityFix pattern (same for all)
Files changed
schema/charts/metric.tsposition,title_weight, secondaryalignmentstransforms/charts/metric.tssecondaryAlignto read from secondary metricschema/charts/xy.tsdecoration_position(auto/left/right) to reference linetransforms/charts/xy/api_layers.ts,state_layers.tsdecoration_positionschema/charts/pie.ts,treemap.ts,mosaic.ts,waffle.tsposition,valuesto legend (withmaxSize: 2)transforms/charts/partition.tslegendPositionschema/charts/datatable.tsshow_row_numbersto_api/appearance.ts,to_state/appearance.tsbuildShowRowNumbershelperschema/charts/heatmap.tsaria_label)transforms/charts/heatmap/to_api.ts,from_api.tsschema/charts/gauge.tsrespect_ranges,common_labeltransforms/charts/gauge.tsschema/color.tscontinuityto color-by-valuetransforms/coloring.tscontinuityReview feedback addressed
icon_positiontodecoration_positionand limited values toauto|left|right(removedabove/below)aria_labelfrom heatmap API (inferred, not user-facing)legendStatsfrom treemap mock (not exposed in treemap UI)buildShowRowNumbershelper to follow existing datatable patternmaxSize: 2to legendvaluesarrays in partition schemasTest plan
feature_flags.overrides: { lens.apiFormat: true }inkibana.yml:yarn test:jest src/platform/packages/shared/kbn-lens-embeddable-utils/config_builder/tests/— 273/273 passyarn test:jest src/platform/packages/shared/kbn-lens-embeddable-utils/config_builder/schema/— 660/660 passyarn test:type_check --project src/platform/packages/shared/kbn-lens-embeddable-utils/tsconfig.json— passes