-
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
refactor: scales #1410
refactor: scales #1410
Conversation
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.
Ok I've gone through all the code changes with the exceptions of the scale_continuous.ts
. I need to dig a little deeper into that file and start playing around with storybook.
packages/charts/src/chart_types/xy_chart/state/selectors/get_axis_styles.ts
Show resolved
Hide resolved
packages/charts/src/chart_types/xy_chart/state/selectors/on_element_out_caller.ts
Outdated
Show resolved
Hide resolved
packages/charts/src/chart_types/xy_chart/state/selectors/on_element_over_caller.ts
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.
packages/charts/src/chart_types/heatmap/state/selectors/get_x_axis_right_overflow.ts
Show resolved
Hide resolved
packages/charts/src/chart_types/xy_chart/state/selectors/on_pointer_move_caller.ts
Outdated
Show resolved
Hide resolved
@@ -128,7 +126,7 @@ export function computeSeriesDomains( | |||
// fill series with missing x values | |||
const filledDataSeries = fillSeries(dataSeries, xValues, xDomain.type); | |||
|
|||
const seriesSortFn = getRenderingCompareFn(sortSeriesBy, (a: SeriesIdentifier, b: SeriesIdentifier) => { | |||
const seriesSortFn = getRenderingCompareFn(void 0, (a: SeriesIdentifier, b: SeriesIdentifier) => { |
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.
Just remember to grep all void 0
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.
or enable no-void
eslint rule
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.
As there was no current demand for retaining sortSeriesBy
, its removal got completed: the void 0
s are removed altogether f2f27e9
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.
Added ec90371 which turns voids into warnings. It's legit JS and there's no fundamental reason for avoiding it, other than maybe uniform greppability, which isn't very valuable as undefined
values can legitimately generated in all kinds of ways like optionals, so not sure when we'd grep for undefined
. So, on the fence about discouraging perfectly good JS
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 idea to me is to prevent uncommon javascript syntax, so when 3rd party contributions come in they are not confused. I bet you 1 in 5 javascript engineers know what void 0
is. If
statements are also perfectly fine JS but yet this PR removes dozens 😉, just saying....
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.
Still waiting on some file changes, lmk when you want me to take a look.
Co-authored-by: Nick Partridge <[email protected]>
Co-authored-by: Nick Partridge <[email protected]>
Co-authored-by: Nick Partridge <[email protected]>
Co-authored-by: Marco Vettorello <[email protected]>
Pls let's preformat our suggestions in our IDE, otherwise our hypersensitive CI will yield a bunch of big red crosses due to a couple of spaces 🤣 Also, we get the "red card" for incomplete test runs, which is awkward, b/c it disincentivizes the otherwise normal process of applying suggestions one after the other, such that there's no time for CO to complete |
I ended up reverting the "chore: untangle continuous scales file" commit, because it has served its purpose (allowing side by side comparison) and I'd like to avoid merge conflicts in that code. Also, the new order is I think more in line with what Cartesian code seems to follow, which is, put the main thing (class or function) atop, and place most utilities and nuisance bits (looking at you, loong type description) below |
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.
New changes LGTM.
Thanks, just saw your reply, let's figure out something over time, as for
every verbified function we also have maybe significant or even several
non-verbed ones
…On Tue, 5 Oct 2021 at 15:59, Nick Partridge ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In packages/charts/src/chart_types/xy_chart/utils/axis_utils.ts
<#1410 (comment)>
:
> +/** @internal */
+export function tickLabelPosition(
{ tickLine, tickLabel }: AxisStyle,
This is a tough one because I don't feel this is good JAVASCRIPT best
practices. If it comes up again every 3 weeks it will start to get
distracting. Until we switch to some other language I don't think is a
legitimate concern. Even if we somehow all agree to this we will have to
account for dozens of naming collisions (i.e. const tickLabelPosition =
tickLabelPosition()) and implement it throughout the library consistently.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1410 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAL2BZCQJYVKNJ67AHFR55TUFMAC5ANCNFSM5EXRGELQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
# [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
Refactoring toward making scales more independent of a preconceived tick count, so the future version of
getAvailableTicks
can try various tick counts, and possibly even extend the domain. This is needed by both the hierarchical time axis and the solution for avoiding duplicate or misplaced ticks. Miscellaneous additional simplificationsDetails
Scale.scale()
andScale.pureScale()
always return anumber
instead of the union type (emittingNaN
instead ofnull
and downstream checks as before but withNumber.isNaN
,Number.isFinite
,scale(val) || 0
etc. so no behavioral change is expected)sortSeriesBy
which wasn't exercised by unit tests, VRT or Kibana, yet its former presence required multiple@ts-ignore
s which are now also removedisNaN
s with clearer alternatives (it coerces, eg.isNaN(null)
andisNaN("42")
yieldfalse
)showOverlappingTicks
toticksForCulledLabels
LogScaleOptions.logBase
is now anumber
instead of the object enumLogBase
; duplicate enum->number mappers removed too. Shorter, and allows other bases (octal, hex, 1024 etc.)scaleOrThrow
and all other...orThrow
functions, now just handling certainNaN
/non-finiteness cases, except for geom string generation. These used to silently swallow errors in past (hypothetical? IRL experienced?) cases where some D3 scale were to return a non-finite value, or even, throw an error, so geoms silently don't show up. The new behavior is that if the D3 scale were to throw, there's an explicit, clear error, and if there's aNaN
or similar, then the geom path will have it, and an explicit console log line will be written. There are pros&cons so this may be an item up for debate, as the nature and type of our defensiveness, and swallow vs. expose errors are concernedScaleContinuous
, for example, the constuctor is split to tick count independent part vs tick count dependent partgetAvailableTicks
andgetVisibleTicks
into a newgetVisibleTicks
(for this reason, unit tests that exercised these separately are currently commented out)true
orfalse
, the ternary is superfluous)mergePartial
axis_utils
), type updates (fewer optional parameters, fewer union types etc.) and minor fixes (eg. non-integer desired tick count)I also had to backtrack on (stash) more ambitious changes for now, such as improving the scale typing, I timeboxed it and didn't reach the goal in time
Issues
Checklist
:xy
,:partition
):interactions
,:axis
):theme
label has been added and the@elastic/eui-design
team has been pinged when there areTheme
API changescloses #123
,fixes #123
)packages/charts/src/index.ts