-
Notifications
You must be signed in to change notification settings - Fork 122
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)!: change timeAxisLayerCount
the default from 0
to 2
#2582
base: main
Are you sure you want to change the base?
Conversation
timeAxisLayerCount: 2
the defaulttimeAxisLayerCount: 2
the default
@walterra FYI, to update any playwright snapshots you can comment on the PR with..
This will run the ci in update mode and push a commit to your branch with the updated e2e screenshots, if any. The reason we need to run this in the CI is due to slight differences in the browser binaries between MacOS and linux ci agents. So to avoid this we only store screenshots generated from ci. And to just trigger a re-run of the ci you can comment...
|
6b22f3a
to
fd7ac96
Compare
timeAxisLayerCount: 2
the defaulttimeAxisLayerCount
the default from 0
to 2
timeAxisLayerCount
the default from 0
to 2
timeAxisLayerCount
the default from 0
to 2
timeAxisLayerCount
the default from 0
to 2
timeAxisLayerCount
the default from 0
to 2
@@ -81,24 +81,7 @@ export const Example: ChartsStory = (_, { title, description }) => { | |||
}, |
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.
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.
This reason for this regression: We now have to check for both timeAxisLayerCount > 0
and if the scale type is time
, however, the lowest chart uses ordinal
.
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.
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.
With the update (c6fdc74) to use enableHistogramMode:true
for time based x-axis the axis now render the same across all three charts:
@@ -132,7 +132,7 @@ Show duplicated ticks | |||
|
|||
### `timeAxisLayerCount` | |||
- Type: <code>timeAxisLayerCount: number</code> | |||
- Default: `0` | |||
- Default: `2` |
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.
Posting this here for reference to start a thread, because the affected example file has not been touched.
There's a baseline change for stories with custom markers. Previously the axis ticks and markers would render overlapping, now they render with additional offset. Is the new version ok? I'm not sure the original overlapping was intentional or a bug?
3a7832f
to
abddedc
Compare
) => { | ||
const { tickLine, axisTitle, axisPanelTitle, tickLabel } = axesStyles.get(axisSpec.id) ?? sharedAxesStyles; | ||
const horizontal = isHorizontalAxis(axisSpec.position); | ||
const maxLabelBoxGirth = horizontal ? maxLabelBboxHeight : maxLabelBboxWidth; | ||
const allLayersGirth = getAllAxisLayersGirth(axisSpec.timeAxisLayerCount, maxLabelBoxGirth, horizontal); | ||
const isMultilayerTimeAxis = isMultilayerTimeAxisFn({ axisSpec, scaleConfigs, rotation }); |
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.
This could be named const multilayerTimeAxis = isMultilayerTimeAxis(...)
instead, wdyt?
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.
Yes, agree
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.
updated in b07adcf.
) => { | ||
const { tickLine, axisTitle, axisPanelTitle, tickLabel } = axesStyles.get(axisSpec.id) ?? sharedAxesStyles; | ||
const horizontal = isHorizontalAxis(axisSpec.position); | ||
const maxLabelBoxGirth = horizontal ? maxLabelBboxHeight : maxLabelBboxWidth; | ||
const allLayersGirth = getAllAxisLayersGirth(axisSpec.timeAxisLayerCount, maxLabelBoxGirth, horizontal); | ||
const isMultilayerTimeAxis = isMultilayerTimeAxisFn({ axisSpec, scaleConfigs, rotation }); |
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.
Yes, agree
alignment: { | ||
vertical: Position.Bottom, | ||
horizontal: Position.Left, | ||
}, |
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.
For some reason multiple tests shows centered aligned bars instead of left aligned bars. The first example is here https://ech-e2e-ci--pr-2582-n5t2yfqp.web.app/e2e-report/#?testId=4a59eca736035d93205f-0a486745228f4b4ff460

Do you mind checking and see why the bars are centered?
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.
To me it looks like they were centered before too, it wasn't just as obvious because the date axis labels didn't have ticks. If you compare the grid and annotations they are the same in both charts, aren't they? It looks to me like BarSeries
is always centered, and just HistogramBarSeries
will left-align the bars. (Like the Rendering Bars example that already used timeAxisLayerCount=2
.
Should we update examples with time axis to always use HistogramBarSeries
? (If yes I'd prefer to do that in a follow up to make review easier for just that change)
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.
Here's how the example renders now with using enableHistogramMode:true
for charts with a time based x-axis. (c6fdc74)
2f97696
to
125b36b
Compare
packages/charts/src/chart_types/xy_chart/renderer/canvas/axes/tick.ts
Outdated
Show resolved
Hide resolved
packages/charts/src/chart_types/xy_chart/renderer/canvas/axes/tick_label.ts
Outdated
Show resolved
Hide resolved
packages/charts/src/chart_types/xy_chart/renderer/canvas/panels/title.ts
Outdated
Show resolved
Hide resolved
125b36b
to
fc7edea
Compare
@markov00 I updated code related to |
c3b3570
to
c6fdc74
Compare
const constraints: Pick<typeof props, 'enableHistogramMode'> = {}; | ||
|
||
// enable histogram mode for time scales to align with the multi-layer time axis. | ||
if (props.xScaleType === ScaleType.Time) { | ||
constraints.enableHistogramMode = true; | ||
} | ||
|
||
useSpecFactory<BarSeriesSpec<D>>({ ...defaults, ...stripUndefined(props), ...overrides, ...constraints }); |
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.
@markov00 Is this the right place to update enableHistogramMode
internally? I saw the goal chart does something similar. Is this sufficient or do we also need to check for rotation (e.g. to be 0 or 180) here?
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.
I think is fine checking just this, the rotation is not necessary I believe
✅ Successful Deployment (build#4562) - c6fdc74 |
Summary
timeAxisLayerCount: 2
is now the default to render multiple layers for time based axes. This feature was originally added in 2021 and now just a small set of consumers are using the legacy time axis.BREAKING CHANGE
The
timeAxisLayerCount
options now defaults to2
instead of0
.Details
timeAxisLayerCount
defaulted to0
, code in some places assumed that a change to2
was only done by users when the x axis was then time based. Thus changing the default to2
changed the calculated padding for all axis types.timeAxisLayerCount
is set to2
, there was no check for axes if they were actually time based. This means this also affected vertical axes so the left and right margin would change. I think that's the reason why we see so many baseline changes in the playwright e2e image assertions.Issues
This PR is part of elastic/kibana#193683
Checklist
:xy
,:partition
):interactions
,:axis
)closes #123
,fixes #123
)packages/charts/src/index.ts
light
anddark
themes