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

feat(xy): apply the data value formatter to data values over bars #1419

Merged
merged 19 commits into from
Oct 15, 2021

Conversation

rshen91
Copy link
Contributor

@rshen91 rshen91 commented Oct 4, 2021

Summary

The tickFormat on the data values over bars now will correctly display when charts are rotated.

Details

PR #1390 includes some old commits changing the nature of getAxesBySpecId() but this function is used in multiple places where rotations were already accounted for. This new approach in this PR does not impact the tooltip header or body formatting, rectangular annotations, legend formatting etc.

Issues

Closes #1387

Checklist

  • The proper chart type label has been added (e.g. :xy, :partition)
  • 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
  • The proper documentation and/or storybook story has been added or updated

@rshen91 rshen91 added :chart Chart element related issue :xy Bar/Line/Area chart related labels Oct 4, 2021
@rshen91
Copy link
Contributor Author

rshen91 commented Oct 4, 2021

@markov00 just wanted to confirm with the with value label story that the rotation in commit 06bef45 seems fine. There isn't a tick formatter for the bottom axis and the data for the non-stacked series isn't whole number data, so I think the formatting is working ok.

[
   {x: 0, y: 3.934269, g: 'b'},
   {x: 1, y: 7.662253926666667, g: 'b'},
   {x: 2, y: 7.043862173333342, g: 'b'},
   {x: 3, y: 6.394734540000064, g: 'b'},
   {x: 4, y: 6.059608170666939, g: 'b'},
   {x: 5, y: 0.25, g: 0},
   {x: 6, y: 8, g: 0}
]

Let me know what you think, thank you.

@rshen91 rshen91 marked this pull request as draft October 6, 2021 13:26
Copy link
Member

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

To nicely verify that the correct formatter is applied on rotation please add two different formatters that can help identify the formatter on the value something like:

  • for the horizontal axis: ${number.toFixed(2)} H
  • for the vertical axis: ${number.toFixed(2) V}

This renders better nicely the values and shows the H or the V on the bar values that is easier to match that a missed formatter.

@rshen91
Copy link
Contributor Author

rshen91 commented Oct 11, 2021

Checked through the failures in the vrts commit 8e768d2 - small formatting changes applied on the https://elastic.github.io/elastic-charts/?path=/story/bar-chart--with-value-label&globals=theme:light stories with rotations. Updated vrts in bar stories in 3c3a349

@rshen91 rshen91 marked this pull request as ready for review October 11, 2021 18:43
@rshen91 rshen91 requested a review from markov00 October 11, 2021 18:43
@rshen91 rshen91 requested a review from markov00 October 12, 2021 19:38
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.

Code changes LGTM.

Comment on lines 133 to 142
eachRotation.describe((rotation) => {
describe.each<NonNullable<DisplayValueStyle['alignment']>['vertical']>([
VerticalAlignment.Middle,
VerticalAlignment.Top,
VerticalAlignment.Bottom,
])('Vertical Alignment - %s', (verticalAlignment) => {
describe.each<NonNullable<DisplayValueStyle['alignment']>['horizontal']>([
HorizontalAlignment.Left,
HorizontalAlignment.Center,
HorizontalAlignment.Right,
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍🏼

Comment on lines 22 to 23
fontSize: 10,
fill: 'black',
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest making this larger because it blends in. For others that view this story I'd be easier to view the change when the value is more pronounced.

Copy link
Member

@markov00 markov00 left a comment

Choose a reason for hiding this comment

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

Looks great, I've added a comment that should probably addressed in this PR to have a nice and clean set of VRTs

@@ -129,6 +129,27 @@ describe('Bar series stories', () => {
});
});

describe('value label positioning and formatting', () => {
Copy link
Member

Choose a reason for hiding this comment

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

This is great, works well and visually is easy to read and check for defects!
I think we can really remove the screenshots and tests that looks similar to this but with a different story (the describe test before this one: value labels positioning.
I think we can remove it, but keeping the additional test in the describe called clip both geometry and chart area values. The reason is the following: that set screenshot is difficult to read, the high decimal values + very thin bars makes it difficult to understand what is the test about (rendering value labels with different configurations)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call - updated vrts in 14182f by deleting the old bar_stories vrts and rerunning.

@rshen91 rshen91 merged commit e673fc7 into elastic:master Oct 15, 2021
nickofthyme pushed a commit that referenced this pull request Oct 15, 2021
# [38.0.0](v37.0.0...v38.0.0) (2021-10-15)

### Bug Fixes

* **deps:** update dependency @elastic/eui to v39 ([#1422](#1422)) ([2ee97aa](2ee97aa))
* **goal:** reduce whitespace for circular charts ([#1413](#1413)) ([6517523](6517523))
* **interactions:** change allowBrushingLastHistogramBin to true ([#1396](#1396)) ([9fa9783](9fa9783))
* **xy:** remove wrongly represented null/missing values in tooltip ([#1415](#1415)) ([e5963a3](e5963a3)), closes [#1414](#1414)

### Code Refactoring

* scales ([#1410](#1410)) ([a53a2ba](a53a2ba))

### Features

* **scales:** add `LinearBinary` scale type ([#1389](#1389)) ([9f2e427](9f2e427))
* **xy:** adaptive tick raster ([#1420](#1420)) ([200577b](200577b))
* **xy:** apply the data value formatter to data values over bars ([#1419](#1419)) ([e673fc7](e673fc7))

### BREAKING CHANGES

* **interactions:** allowBrushingLastHistogramBucket renamed to allowBrushingLastHistogramBin on the Settings component defaults true and is only applied for histogram type charts
* LogScaleOptions.logBase` is now a `number` instead of the object enum `LogBase`. Some edge case data or configuration _might_, with a deemed low likelihood, lead to a situation where the earlier version would have silently not rendered a bar, line or point, while the new code doesn't `catch`, therefore throw an exception (see the last item). General risk of regressions due to the quantity of code changes (altogether 3.5k)
@nickofthyme
Copy link
Collaborator

🎉 This PR is included in version 38.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@nickofthyme nickofthyme added the released Issue released publicly label Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:chart Chart element related issue released Issue released publicly :xy Bar/Line/Area chart related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong tickFormat applied to the value labels
3 participants