elastic-charts icon indicating copy to clipboard operation
elastic-charts copied to clipboard

fix(cartesian): fill missing datapoints only for stacked area charts

Open markov00 opened this issue 3 years ago • 1 comments

Summary

This PR fixes an issue caused by a mixed configuration with a data fill functionality, the fit functionality within a band chart.

There are multiple factors that are causing the rendering error in #1683:

  • the fit functionality doesn't work for band charts yet, it applies the fit function only to the y1 values
  • we are wrongly filling charts with null data points on every missing x value depending on some wrongly configured constraints.
  • when rendering a band both y values needs to exist to be considered a defined value. If only one is missing, then that band section is considered not defined and will not be rendered.

The mix of these factors cause the issue linked below.

On master: Screenshot 2022-05-27 at 11 07 39

On this PR: Screenshot 2022-05-27 at 11 09 16

Details

The current dataset filling operation can be described as the following:

  • collect every available value along the X axis across all series
  • if the filling operation is required (a constraint previously defined by negating the isXFillNotRequired method) then we loop through the data array, adding a partial data point (with null Y values) on every missing x datapoint.

I've chosen to fix the current policy on filling data sets with empty X values expressed in the isXFillNotRequired method. I've decided to apply the filling policy only to stacked area charts. The fill policy should be required only for that case because:

  • stacked area charts need to perfectly juxtapose areas on top of each other. If we miss a data point in one area, the area above or below can overlap or not completely touch the nearest area, causing the chart to be wrongly rendered creating a bad data representation.
  • bar chart don't need this fill policy at all.
  • line charts can clearly overlaps, we don't stack line charts so that policy is completely useless.
  • non stacked area charts, behaves like line charts, so to the policy doesn't need to be applied.

Issues

fix #1683

Checklist

  • [x] The proper chart type label has been added (e.g. :xy, :partition)
  • [x] The proper feature labels have been added (e.g. :interactions, :axis)
  • [x] All related issues have been linked (i.e. closes #123, fixes #123)
  • [ ] Unit tests have been added or updated to match the most common scenarios
  • [x] The proper documentation and/or storybook story has been added or updated

markov00 avatar May 27 '22 10:05 markov00

Deployments - af45bea80ba4cf5b8115c4b9b6317995b3414cbb

  • Storybook (link)
  • e2e server (link)
  • Playwright report (link)

elastic-datavis[bot] avatar Jun 29 '22 18:06 elastic-datavis[bot]