-
Notifications
You must be signed in to change notification settings - Fork 121
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: outside rect annotation placement and group relations #2471
Conversation
@@ -40,7 +43,7 @@ export function computeRectAnnotationDimensions( | |||
isHistogram: boolean = false, | |||
): AnnotationRectProps[] | null { | |||
const { dataValues, groupId, outside, id: annotationSpecId } = annotationSpec; | |||
const { xAxis, yAxis } = getAxesSpecForSpecId(axesSpecs, groupId); | |||
const { xAxis, yAxis } = getAxesSpecForSpecId(axesSpecs, groupId, chartRotation); |
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.
Needed to match to correct axis
if (outside) { | ||
if (hasXValues && hasYValues) { | ||
Logger.warn( | ||
`The RectAnnotation (${annotationSpecId}) was defined as outside but has both x and y values defined.`, | ||
); |
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.
Warns when attempting to render annotation as outside
but both x and y coordinates are defined. The outside
annotation should be limited to a single axis. Renders inside as fallback to avoid not rendering at all.
buildkite update screenshots |
buildkite update screenshots |
## [66.0.4](v66.0.3...v66.0.4) (2024-06-24) ### Bug Fixes * **deps:** update dependency @elastic/eui to v95 ([#2462](#2462)) ([040c354](040c354)) * option to disable the isolated point styles on line and area charts ([#2472](#2472)) ([ae16815](ae16815)) * outside rect annotation placement and group relations ([#2471](#2471)) ([d46fb41](d46fb41))
Summary
This PR fixes an issue with
RectAnnotation
when defined asoutside
. Now alloutside
RectAnnotation
s render correctly within their respectiveAxis
.Details
This prop is meant to render the annotation outside of the chart in the axis area, however this only works when there is an arbitrary
groupId
applied, because this would cause theyScale
to be undefined as if it's the same case as fixed in #842.This was due to a combination of errors in the logic. First was the missing rotation when looking up the axis specs here...
elastic-charts/packages/charts/src/chart_types/xy_chart/annotations/rect/dimensions.ts
Line 43 in ae2af1c
This would provide wrong axis for the given annotation. I have now made the
rotation
argument required to avoid this error in the future.Secondly, the logic to determine the placement dimensions of the
outside
annotation was extremely limiting for all cases particularly related to chart rotations.elastic-charts/packages/charts/src/chart_types/xy_chart/annotations/rect/dimensions.ts
Lines 77 to 81 in ae2af1c
This was fixed by factoring in each case for rotation and domain, as is done for the
LineAnnotation
markers.Issues
fixes #2470
Checklist
:xy
,:partition
):interactions
,:axis
)closes #123
,fixes #123
)packages/charts/src/index.ts