kibana icon indicating copy to clipboard operation
kibana copied to clipboard

[XY] Migrate vis type xy to new unified xy expression

Open VladLasitsa opened this issue 2 years ago • 37 comments

Completes part of https://github.com/elastic/kibana/issues/127115

Summary

Migrate existing vis type xy implementation to the new unified xy expression. As part of this the following changes was made in unified xy expression:

  • Moved curveType inside data layer expression functions as we can configure different curve types for different layers.
  • Expanded constants of fitting functions
  • Added supporting of vis dimension for Accessors from ExtendedDataLayer (as part of that the table arg was removed)
  • Added splitColumnAccessor and splitRowAccessor for layeredXyVis function
  • Added toggle legend button and legend color picker
  • Added enforce argument in axis extent so that ignore extents validation
  • Updated logic for x-domain to use adjusted interval by using function -> getAdjustedInterval from src/plugins/charts/public/static/components/endzones.tsx
  • Fixed problem with formatting for splitted charts when we use range
  • Fixed problem with scrolling of legend when we use new expression in vis editor
  • Fixed problem with logging datatable for inspector (added missing accessors, log only one datatable for vis type xy)
  • Fixed problem with direction of splitting by row and by column: before split by row uses splitHorizontally, now it was uses splitVertically prop.

VladLasitsa avatar Jul 15 '22 10:07 VladLasitsa

The delay agg test fails because of this: This is how the table looks like (it's using a split series column which is always empty) Screenshot 2022-07-19 at 13 54 47

But in the new renderer, we do this (basically filtering out a table if the split series is not defined): https://github.com/elastic/kibana/blob/6d1ba64bc59e928393beb31510293846b41b821b/src/plugins/chart_expressions/expression_xy/public/helpers/layers.ts#L102

I think this behavior is fine and it's kind of bad luck this test breaks. The easiest way to work around it I found is to map the shard delay agg to a chart split instead of a split series (you just have to change the schema to split instead of group for the shard delay agg in https://github.com/elastic/kibana/blob/6c93e3ded723fa38dff83bf09eb20123c1b33264/x-pack/test/functional/fixtures/kbn_archiver/dashboard_async/async_search.json#L53

flash1293 avatar Jul 19 '22 11:07 flash1293

Pinging @elastic/kibana-vis-editors @elastic/kibana-vis-editors-external (Team:VisEditors)

elasticmachine avatar Jul 21 '22 14:07 elasticmachine

@elasticmachine merge upstream

VladLasitsa avatar Jul 21 '22 14:07 VladLasitsa

About the handleEmptyXAccessor - I think we can solve this without introducing a new hyper-specific argument. As we know whether there is no x accessor during expression build time, let's do it like this instead: If there is no x accessor during building the expression:

  • Pass all as x accessor
  • Pass All docs as xAxisConfig.title
  • In the expression building logic, before the layeredXyVis function call add | staticColumn name="all" value="_all"

For the renderer this column should behave like a "real" column, so we don't need any extra logic in the renderer and no additional argument

flash1293 avatar Jul 25 '22 09:07 flash1293

About the handleEmptyXAccessor - I think we can solve this without introducing a new hyper-specific argument. As we know whether there is no x accessor during expression build time, let's do it like this instead: If there is no x accessor during building the expression:

  • Pass all as x accessor
  • Pass All docs as xAxisConfig.title
  • In the expression building logic, before the layeredXyVis function call add | staticColumn name="all" value="_all"

For the renderer this column should behave like a "real" column, so we don't need any extra logic in the renderer and no additional argument

done.

VladLasitsa avatar Jul 25 '22 12:07 VladLasitsa

The color picking on dashboard seems to work, but it does not pick up existing colors.

  • Configure an agg based xy chart off this PR (either main or on a released version) and set a color on a dashboard
  • Export the dashboard and import it into a instance running this PR
  • Default color is shown instead of picked color

Fixed.

VladLasitsa avatar Jul 25 '22 12:07 VladLasitsa

As discussed offline, the behavior of useAdjustedInterval always make sense - we can remove the argument and always trigger this behavior

flash1293 avatar Jul 25 '22 15:07 flash1293

As discussed offline, the behavior of useAdjustedInterval always make sense - we can remove the argument and always trigger this behavior

done

VladLasitsa avatar Jul 26 '22 09:07 VladLasitsa

Create new vertical bar chart, change chart type for the first metric to "Line" - crash: Screenshot 2022-07-27 at 11 36 29 Screenshot 2022-07-27 at 11 37 29

flash1293 avatar Jul 27 '22 09:07 flash1293

New implementation throws on active time marker setting, without date histogram old implementation ignores it: Screenshot 2022-07-27 at 11 51 20

flash1293 avatar Jul 27 '22 09:07 flash1293

Dashed and dot-dashed styles look different: Screenshot 2022-07-27 at 11 53 44

flash1293 avatar Jul 27 '22 09:07 flash1293

Clicking a data point in a split chart ignores the split chart dimension. Like this chart: Screenshot 2022-07-27 at 11 57 03

Clicking a data point will just apply the time filter from the x axis while on main it will show the modal for the split chart filter

flash1293 avatar Jul 27 '22 09:07 flash1293

Other bucket on date field doesn't render properly: Screenshot 2022-07-27 at 12 00 10

flash1293 avatar Jul 27 '22 10:07 flash1293

In horizontal bar chart the labels are angled the other way ( the way it used to work seems better to me): Screenshot 2022-07-27 at 12 00 39

flash1293 avatar Jul 27 '22 10:07 flash1293

Show labels setting is ignored (on all axes): Screenshot 2022-07-27 at 12 03 46

flash1293 avatar Jul 27 '22 10:07 flash1293

"Vertical" alignment on axis labels is 180 degrees rotated: Screenshot 2022-07-27 at 12 05 47

flash1293 avatar Jul 27 '22 10:07 flash1293

Dot size ratio is not interpreted in the same way - the dots are much larger in the new version: Screenshot 2022-07-27 at 12 09 33

flash1293 avatar Jul 27 '22 10:07 flash1293

Axis extents are ignored: Screenshot 2022-07-27 at 12 19 27

flash1293 avatar Jul 27 '22 10:07 flash1293

@flash1293 I fixed all your remarks. Could you please review again?

VladLasitsa avatar Jul 27 '22 14:07 VladLasitsa

@elasticmachine merge upstream

VladLasitsa avatar Jul 28 '22 12:07 VladLasitsa

It looks like on existing visualizations the legend visibility is ignored:

Flights sample data (left is new, right is old) Screenshot 2022-08-02 at 10 42 13

flash1293 avatar Aug 02 '22 08:08 flash1293

Seems like it's never persisted in the new version

flash1293 avatar Aug 02 '22 08:08 flash1293

Scale to data bounds is still ignored for bar charts: Screenshot 2022-08-02 at 10 54 30

flash1293 avatar Aug 02 '22 08:08 flash1293

If there are multiple metrics, their names are not added to the legend entry anymore (left is PR, right is main): Screenshot 2022-08-02 at 11 03 23

Also, the color assignment is different now (it used to be identical to Lens before) (left is PR, right is main): Screenshot 2022-08-02 at 11 11 11

flash1293 avatar Aug 02 '22 09:08 flash1293

Also the tooltip is wrong if there are multiple metrics - it's always showing the name of the first:

PR: Screenshot 2022-08-02 at 11 13 43

Main: Screenshot 2022-08-02 at 11 13 39

flash1293 avatar Aug 02 '22 09:08 flash1293

This works as expected, I found some small bugs:

  • When the user selects the compatibility palette, the overwrite colors (that appear when the user clicks a legend item) should be from the compatibility palette and not from the default EUI. This is a screenshot with the expected colors image

  • Percentiles are not colored correctly, neither the percentile ranks image

  • The dot size information is not depicted on the detailed tooltip image

  • hiding the second y layer breaks the chart image

stratoula avatar Aug 02 '22 10:08 stratoula

@elasticmachine merge upstream

VladLasitsa avatar Aug 03 '22 11:08 VladLasitsa

@elasticmachine merge upstream

VladLasitsa avatar Aug 08 '22 07:08 VladLasitsa

Thanx Vlad! I found another bug. The overwrite color doesnt work for multiple metrics image

Moreover, splitting a percentiles metric works differently. (same for percentile ranks)

In main. (check the legend order in comparison with the screenshot below) image

Same chart here image

stratoula avatar Aug 08 '22 08:08 stratoula

Also the split series order seems wrong (possibly related to the percentiles bug mentioned above)

image

stratoula avatar Aug 08 '22 08:08 stratoula