feat(xy): adaptive tick raster#1420
Conversation
58e548f to
09121f9
Compare
33835fe to
b0bab66
Compare
…ess in its timezone
222d8b9 to
fbe20ba
Compare
fbe20ba to
b85648f
Compare
| ], | ||
| 'sort-keys': 0, | ||
| 'no-irregular-whitespace': 'error', | ||
| 'no-irregular-whitespace': 'warn', |
There was a problem hiding this comment.
It's fair play to use non-breaking space or whatever in strings. If such a value is commented out, it triggers this condition, and it can't be locally bypassed with an ignore line
| }; | ||
|
|
||
| /** @internal */ | ||
| export function getAxesDimensions( |
There was a problem hiding this comment.
The former getAxesDimensions got split into a reducer part (this here) and an actual calculation part (getAxisSizeForLabel)
| return axisLayerCount * maxLabelBoxGirth; | ||
| }; | ||
|
|
||
| const getAxisSizeForLabel = ( |
There was a problem hiding this comment.
The logic in getAxisSizeForLabel matches the former calc in getAxesDimensions except for the use of getAllAxisLayersGirth which permits an axis girth reflecting multiple axis tick layers
| const maxLabelBoxSize = horizontal ? maxLabelBboxHeight : maxLabelBboxWidth; | ||
| const labelSize = tickLabel.visible ? maxLabelBoxSize + innerPad(tickLabel.padding) + outerPad(tickLabel.padding) : 0; | ||
| const maxLabelBoxGirth = horizontal ? maxLabelBboxHeight : maxLabelBboxWidth; | ||
| const allLayersGirth = getAllAxisLayersGirth(tickLabel, maxLabelBoxGirth, horizontal); |
| ); | ||
|
|
||
| /** @internal */ | ||
| export const getLabelBox = ( |
There was a problem hiding this comment.
Breaking out this from computeAxisTicksDimensionsSelector in part to detach the logic from the reduction, and in part to enable reuse of the logic
| export const axisSpecsLookupSelector = createCustomCachedSelector( | ||
| getAxisSpecsSelector, | ||
| (axisSpecs: AxisSpec[]): Map<string, AxisSpec> => axisSpecs.reduce((acc, spec) => acc.set(spec.id, spec), new Map()), | ||
| ); |
106c0d8 to
4af0a38
Compare
|
test this |
There was a problem hiding this comment.
Code changes LGTM
Tested locally
The changes on the number of ticks in a log scale are done on purpose to improve the scale reading.
There are few TODOs to fix on a subsequent PR:
- there is a visible reduction of the number of ticks rendered for "standard" time axis, this happens due to the changes in the cadence on the time intervals (we don't allow 2 min steps for example, but we allow only 1 minute or 5 minute steps). This, if needed can be fixed in a subsequent PR
- fix the generation of too many ticks under specific conditions (see the high volume story) (see VRT related changes)
- remove the double-time axis example from storybook (one VRT to remove)
- fix the deduplication under specific conditions: with non-time axis we should keep all the generated ticks and avoid the filtering in
enableDuplicatedTicksto make the ticks reduction works correctly. (a VRT with wrong deduplication rendering was added and that need to be fixed ff686d7)
nickofthyme
left a comment
There was a problem hiding this comment.
Code change LGTM, tested logic in storybook and looks to match defined conditions.
The time ticks are definitely more sparse than previously but I think this is cover in the future work.
I appreciate the added ticks for missing labels, I'd like to see this go future where we can define primary and secondary ticks and labels say 1000s on primary and 100 on secondary. I see similarities between this idea and the timeslip multilayer axis.
| /* | ||
| const midAxisLabelFormatter = (d: any) => | ||
| `${whiskers ? ' ' : ''}${new Intl.DateTimeFormat('en-US', { hour: 'numeric' }).format(d).padStart(2, '0')} `; | ||
| const bottomAxisLabelFormatter = (d: any) => | ||
| `${whiskers ? ' ' : ''}${new Intl.DateTimeFormat('en-US', { | ||
| year: 'numeric', | ||
| month: 'long', | ||
| day: 'numeric', | ||
| }).format(d)} `; | ||
| */ |
There was a problem hiding this comment.
Can we avoid committing comments? It's just the same to add a boolean knob here that uses this formatter or another. Commenting it serves no purpose.
There was a problem hiding this comment.
I agree, though as it's just a story, it might be fine for a short time, the upcoming PR removes this file
# [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)
|
🎉 This PR is included in version 38.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Summary
PR for lowering the targeted tick count until a compliant tick raster is the result. Compliance criteria are informed by the need to convey truth on the chart, and also by dataviz best practices:
Details
The current method relies on tick label culling (and optionally, tick/gridline culling) for avoiding overlap and duplicated tick labels, but the (inherently post hoc) culling of the tick labels doesn't guarantee compliance with the above items. For examples:
In short, we deactivate the culling of a single raster; instead, we iteratively generate the raster that's closest to the desired tick count, while complying with the rules
adaptiveTickCountis set tofalse, ie. old mode, to make all but one VRT images identical with the current snapshotsIssues
Checklist
:xy,:partition):interactions,:axis):themelabel has been added and the@elastic/eui-designteam has been pinged when there areThemeAPI changescloses #123,fixes #123)packages/charts/src/index.tsdark,light,eui-dark&eui-light