Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rendering): area, line and point rendered on the same layer for each series #290

Merged
merged 4 commits into from
Aug 13, 2019

Conversation

markov00
Copy link
Member

@markov00 markov00 commented Aug 6, 2019

Summary

This commit change the rendering order of the line series and area series.
For lines we render: for each series the line and each data point, instead of rendering first all the lines and than all the points.
For areas, depending if the area is stacked or not:

  • if stacked, we render fist all the areas, than all the lines and than all the points (this will avoid having a lines partially rendered below the above area)
  • if non stacked, we render groups of areas, line, points. so each group id rendered on a different layer.

This PR also remove completely the animation from lines and areas as its currently disabled in the library. We will reintegrate the animation in a future release.

fix #287

before
Screenshot 2019-08-06 at 11 35 06

Screenshot 2019-08-09 at 20 12 01

after
Screenshot 2019-08-06 at 11 35 21

Screenshot 2019-08-09 at 20 11 33

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

  • [ ] Any consumer-facing exports were added to src/index.ts (and stories only import from ../src except for test data & storybook)
  • [ ] This was checked for cross-browser compatibility, including a check against IE11
  • [ ] Proper documentation or storybook story was added for features that require explanation or tutorials
  • [ ] Unit tests were updated or added to match the most common scenarios
  • Each commit follows the convention

This commit change the rendering order of the line series. Now we render: for each series the line
and each data point, instead of rendering first all the lines and than all the points

fix elastic#287
@markov00 markov00 added bug Something isn't working :chart Chart element related issue labels Aug 6, 2019
@codecov-io
Copy link

codecov-io commented Aug 6, 2019

Codecov Report

Merging #290 into master will decrease coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #290      +/-   ##
==========================================
- Coverage   98.17%   98.14%   -0.03%     
==========================================
  Files          37       37              
  Lines        2682     3019     +337     
  Branches      617      759     +142     
==========================================
+ Hits         2633     2963     +330     
- Misses         44       49       +5     
- Partials        5        7       +2
Impacted Files Coverage Δ
src/chart_types/xy_chart/store/utils.ts 96.55% <ø> (-0.13%) ⬇️
src/chart_types/xy_chart/rendering/rendering.ts 98.81% <100%> (-0.51%) ⬇️
src/chart_types/xy_chart/legend/legend.ts 100% <0%> (ø) ⬆️
src/chart_types/xy_chart/utils/series.ts 100% <0%> (ø) ⬆️
src/chart_types/xy_chart/utils/specs.ts 100% <0%> (ø) ⬆️
src/chart_types/xy_chart/store/chart_state.ts 97.48% <0%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 759e8b5...c4fffd9. Read the comment docs.


getLineToRender(glyph: LineGeometry, sharedStyle: SharedGeometryStyle, index: number) {
const { line, color, transform, geometryId, seriesLineStyle } = glyph;
const key = `line-${index}`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use something other than the index for the key?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 5d712a5


if (this.props.animated) {
return (
<Group key={index} x={transform.x}>
Copy link
Collaborator

@nickofthyme nickofthyme Aug 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here? re: index

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed on 5d712a5

return (
<Group key={index} x={transform.x}>
<Spring native reset from={{ opacity: 0 }} to={{ opacity: 1 }}>
{() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we extract this function so it doesn't create a new function on each rerender? I don't think it will be that different on performance but best to keep up with best practices.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the animation in 5d712a5

Depending if stacked or not, we draw first all the stacked areas (fist all the areas, then lines
then points). For non stacked elements, we draw groups of area, line, points.
@markov00 markov00 changed the title fix(lines): line and point rendered on the same layer for each series fix(rendering): area, line and point rendered on the same layer for each series Aug 9, 2019
Copy link
Collaborator

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a lot better. I think removing the animations is a good idea for now.

Just have a few comments about the index in the string. I think including that in the key string will cause the component to rerender if the index value changes in the future, at least that's my understanding of react. If the key would be unique without the index I think it should be removed.

src/chart_types/xy_chart/rendering/rendering.ts Outdated Show resolved Hide resolved
src/components/react_canvas/area_geometries.tsx Outdated Show resolved Hide resolved
src/components/react_canvas/area_geometries.tsx Outdated Show resolved Hide resolved
Copy link
Collaborator

@nickofthyme nickofthyme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@markov00 markov00 merged commit 6a4c1b1 into elastic:master Aug 13, 2019
@markov00 markov00 deleted the fix_rendering_order_line branch August 13, 2019 09:55
markov00 pushed a commit that referenced this pull request Aug 13, 2019
## [9.0.3](v9.0.2...v9.0.3) (2019-08-13)

### Bug Fixes

* zIndex order for areas, lines and points ([#290](#290)) ([6a4c1b1](6a4c1b1)), closes [#287](#287)
@markov00
Copy link
Member Author

🎉 This PR is included in version 9.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@markov00 markov00 added the released Issue released publicly label Aug 13, 2019
AMoo-Miki pushed a commit to AMoo-Miki/OpenSearch-Dashboards that referenced this pull request Feb 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working :chart Chart element related issue released Issue released publicly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dots on line charts have sit above all series lines
3 participants