-
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(heatmap): respect margins and paddings #2577
base: main
Are you sure you want to change the base?
Conversation
buildkite test this |
35866a1
to
ee3934d
Compare
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.
The methods in the line.ts
, rect.ts
and text.ts
files were extracted from packages/charts/src/chart_types/xy_chart/renderer/canvas/primitives
folder. In other to avoid duplicates, we need to use these methods in the xy_chart from the packages/charts/src/renderers/canvas/primitives
folder.
As we don't want to increase the number of files, we will do this change in a separate PR.
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.
Created #2586
packages/charts/src/chart_types/heatmap/state/selectors/compute_chart_dimensions.ts
Outdated
Show resolved
Hide resolved
packages/charts/src/chart_types/heatmap/renderer/dom/highlighter_brush.tsx
Outdated
Show resolved
Hide resolved
packages/charts/src/chart_types/heatmap/renderer/canvas/theme.ts
Outdated
Show resolved
Hide resolved
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 can probably remove these methods and call directly the renderDebugRect
passing the right style and dimension
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.
if it is not used in any other place we can remove it and call it directly. But I think that creating a method and calling them with its name looks clearer:
() => debug && renderMargins(ctx, chartContainerDimensions, chartMargins),
() => debug && renderPaddings(ctx, chartContainerDimensions, chartDimensions, chartMargins, chartPaddings),
() => debug && renderChartContainerDimensions(ctx, chartContainerDimensions),
() => debug && renderChartDimensions(ctx, chartDimensions),
const greenSemiTransparent = [...Colors.Green.rgba.slice(0, 3), 0.5] as RgbaTuple; | ||
const lightBlueSemiTransparent = [...Colors.LightBlue.rgba.slice(0, 3), 0.5] as RgbaTuple; |
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.
const greenSemiTransparent = [...Colors.Green.rgba.slice(0, 3), 0.5] as RgbaTuple; | |
const lightBlueSemiTransparent = [...Colors.LightBlue.rgba.slice(0, 3), 0.5] as RgbaTuple; | |
const greenSemiTransparent = [...Colors.Green.rgba.slice(0, 3), 0.5] satisfies RgbaTuple; | |
const lightBlueSemiTransparent = [...Colors.LightBlue.rgba.slice(0, 3), 0.5] satisfies RgbaTuple; |
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 can probably even move these const within each function method. There is no benefit of having that there. These methods are also just for debug purposes so they are not called frequently
chartContainerDimensions: Dimensions, | ||
chartDimensions: Dimensions, | ||
chartMargins: PerSideDistance, | ||
chartPaddings: PerSideDistance, |
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.
nit:
chartContainerDimensions: Dimensions, | |
chartDimensions: Dimensions, | |
chartMargins: PerSideDistance, | |
chartPaddings: PerSideDistance, | |
container: Dimensions, | |
chart: Dimensions, | |
margins: PerSideDistance, | |
paddings: PerSideDistance, |
It could be nice to start cleaning up a bit these naming and reducing redundant labels.
✅ Successful Deployment (build#4421) - 6fcafae |
Summary
The margins and paddings are applied correctly for
heatmap
chart configuration theme.Small multiples
Brush mask and area
Screen.Recording.2025-01-20.at.16.11.46.mov
Details
Add debug option so when is active elements such as margins, paddings, chart dimensions and chart container dimensions are visible.
Issues
fix #2216
Checklist
:xy
,:partition
):interactions
,:axis
)closes #123
,fixes #123
)