-
Notifications
You must be signed in to change notification settings - Fork 120
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(annotation): annotation rendering with no yDomain or groupId #842
Conversation
Codecov Report
@@ Coverage Diff @@
## master #842 +/- ##
==========================================
+ Coverage 70.01% 70.41% +0.40%
==========================================
Files 319 334 +15
Lines 10474 10767 +293
Branches 2221 2266 +45
==========================================
+ Hits 7333 7582 +249
- Misses 3132 3170 +38
- Partials 9 15 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #842 +/- ##
==========================================
+ Coverage 70.01% 70.56% +0.55%
==========================================
Files 321 336 +15
Lines 10508 10801 +293
Branches 2221 2182 -39
==========================================
+ Hits 7357 7622 +265
- Misses 3142 3164 +22
- Partials 9 15 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I just made a few minor comments to fix before merging.
@@ -92,6 +92,7 @@ describe('annotation utils', () => { | |||
showOverlappingLabels: false, | |||
position: Position.Left, | |||
style, | |||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 63a2df1
@@ -105,6 +106,7 @@ describe('annotation utils', () => { | |||
showOverlappingLabels: false, | |||
position: Position.Bottom, | |||
style, | |||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope 😅 ! 63a2df1
@@ -38,7 +38,6 @@ export const computeAnnotationDimensionsSelector = createCachedSelector( | |||
computeSeriesGeometriesSelector, | |||
getAxisSpecsSelector, | |||
isHistogramModeEnabledSelector, | |||
getAxisSpecsSelector, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
/** @internal */ | ||
export interface BrushExtent { | ||
minX: number; | ||
minY: number; | ||
maxX: number; | ||
maxY: number; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
it('annotation with group id should render with x0 and x1 values', () => { | ||
const store = MockStore.default({ top: 0, left: 0, width: 20, height: 200 }); | ||
const settings = MockGlobalSpec.settingsNoMargins(); | ||
const annotation = MockAnnotationSpec.rect({ | ||
groupId: 'group1', | ||
dataValues: [{ coordinates: { x0: 2, x1: 4 } }], | ||
}); | ||
const bar = MockSeriesSpec.bar({ | ||
data: [ | ||
{ x: 1, y: 0 }, | ||
{ x: 2, y: 5 }, | ||
{ x: 4, y: 10 }, | ||
], | ||
}); | ||
MockStore.addSpecs([settings, annotation, bar], store); | ||
const expected = computeAnnotationDimensionsSelector(store.getState()); | ||
const [resultAnnotation] = expected.get('rect_annotation_1') ?? []; | ||
expect(resultAnnotation).toMatchObject({ | ||
rect: { height: 200 }, | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could make these more explicit that the expected value is the height
being passed.
it('annotation with group id should render with x0 and x1 values', () => { | |
const store = MockStore.default({ top: 0, left: 0, width: 20, height: 200 }); | |
const settings = MockGlobalSpec.settingsNoMargins(); | |
const annotation = MockAnnotationSpec.rect({ | |
groupId: 'group1', | |
dataValues: [{ coordinates: { x0: 2, x1: 4 } }], | |
}); | |
const bar = MockSeriesSpec.bar({ | |
data: [ | |
{ x: 1, y: 0 }, | |
{ x: 2, y: 5 }, | |
{ x: 4, y: 10 }, | |
], | |
}); | |
MockStore.addSpecs([settings, annotation, bar], store); | |
const expected = computeAnnotationDimensionsSelector(store.getState()); | |
const [resultAnnotation] = expected.get('rect_annotation_1') ?? []; | |
expect(resultAnnotation).toMatchObject({ | |
rect: { height: 200 }, | |
}); | |
}); | |
it('annotation with group id should render with x0 and x1 values', () => { | |
const height = 200; | |
const store = MockStore.default({ top: 0, left: 0, width: 20, height }); | |
const settings = MockGlobalSpec.settingsNoMargins(); | |
const annotation = MockAnnotationSpec.rect({ | |
groupId: 'group1', | |
dataValues: [{ coordinates: { x0: 2, x1: 4 } }], | |
}); | |
const bar = MockSeriesSpec.bar({ | |
data: [ | |
{ x: 1, y: 0 }, | |
{ x: 2, y: 5 }, | |
{ x: 4, y: 10 }, | |
], | |
}); | |
MockStore.addSpecs([settings, annotation, bar], store); | |
const expected = computeAnnotationDimensionsSelector(store.getState()); | |
const [resultAnnotation] = expected.get('rect_annotation_1') ?? []; | |
expect(resultAnnotation).toMatchObject({ | |
rect: { height }, | |
}); | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool! Makes sense to make this explicit and clear that it's the same as the chartStore height - addressed in 63a2df1
# [24.0.0](v23.2.1...v24.0.0) (2020-10-19) ### Bug Fixes * **annotation:** annotation rendering with no yDomain or groupId ([#842](#842)) ([f173b49](f173b49)), closes [#438](#438) [#798](#798) ### Features * **bar_chart:** add Alignment offset to value labels ([#784](#784)) ([363aeb4](363aeb4)) * **bar_chart:** add shadow prop for value labels ([#785](#785)) ([9b29392](9b29392)) * **bar_chart:** scaled font size for value labels ([#789](#789)) ([3bdd1ee](3bdd1ee)), closes [#788](#788) * **heatmap:** allow fixed right margin ([#873](#873)) ([16cf73c](16cf73c)) ### BREAKING CHANGES * **bar_chart:** The `DisplayValueStyle` `fontSize` property can now express an upper and lower bound as size, used for the automatic scaling. * **bar_chart:** The `DisplayValueStyle` `fill` property can now express a border color and width, or let the library pick the best match based on contrast using the textInvertible parameter.
🎉 This PR is included in version 24.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [24.0.0](elastic/elastic-charts@v23.2.1...v24.0.0) (2020-10-19) ### Bug Fixes * **annotation:** annotation rendering with no yDomain or groupId ([opensearch-project#842](elastic/elastic-charts#842)) ([6bad0d7](elastic/elastic-charts@6bad0d7)), closes [opensearch-project#438](elastic/elastic-charts#438) [opensearch-project#798](elastic/elastic-charts#798) ### Features * **bar_chart:** add Alignment offset to value labels ([opensearch-project#784](elastic/elastic-charts#784)) ([106d924](elastic/elastic-charts@106d924)) * **bar_chart:** add shadow prop for value labels ([opensearch-project#785](elastic/elastic-charts#785)) ([de95b44](elastic/elastic-charts@de95b44)) * **bar_chart:** scaled font size for value labels ([opensearch-project#789](elastic/elastic-charts#789)) ([8b74a9d](elastic/elastic-charts@8b74a9d)), closes [opensearch-project#788](elastic/elastic-charts#788) * **heatmap:** allow fixed right margin ([opensearch-project#873](elastic/elastic-charts#873)) ([dd34574](elastic/elastic-charts@dd34574)) ### BREAKING CHANGES * **bar_chart:** The `DisplayValueStyle` `fontSize` property can now express an upper and lower bound as size, used for the automatic scaling. * **bar_chart:** The `DisplayValueStyle` `fill` property can now express a border color and width, or let the library pick the best match based on contrast using the textInvertible parameter.
Summary
Fixes #438 and #798 where
<Annotations />
were not shown in cases where they should be.<Annotations />
when the y domain is [0, 0] or spans only one value (domain fit is true). In these cases, annotations will now take the chartDimension height:<Annotations />
rendering on the x axis if there is no provided group Id. If there is no group id provided and two y axes, the annotation will not still not show and this behavior is expected since the annotation will not know what y axis to mount onto:Stories (
Zero Domain
andWith Group Id
) are added in Annotations -> Rect section in storybook.Checklist
Delete any items that are not applicable to this PR.