-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Vislib/axis #8174
Vislib/axis #8174
Conversation
I want to start off by saying that many of my recommendations may contradict the style used in the vislib currently, hope that works for you 😸 |
I'm digging into the I have a few ideas about how this could go:
|
const AxisTitle = Private(AxisTitleProvider); | ||
const AxisLabels = Private(AxisLabelsProvider); | ||
const AxisScale = Private(AxisScaleProvider); | ||
const defaults = { |
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.
What do you think about pulling these defaults into a AxisOptions
class? I think the combination of writing these properties to this
, and reading from there and this._attr
is pretty confusing.
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.
in my opinion it would make it more confusing ... maybe not with the axis itself ... but AxisLabels have their own config ... following same pattern we would then need AxisLabelsOptions as well ... and AxisTitleOptions ... and in the future i hope to do similar update to other parts of vislib where this would make even less sense. i think by defining defaults like this its quite clear what all the options that this class can handle are. let me know if you dissagree
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.
My thought was that a single AxisConfig
class could be used across the different Axis___
classes. I was thinking it would help document all of the options in one place, and also would help pass necessary configuration values into AxisScale
and such.
regarding this._attr and this.attr ....
however you probably noticed that then i tried to use this directly ... so instead of having classes store there properties in this._attr they store it directly onto this. i am not sure thats a good idea ... the reason for it would be that the code is easier to read (at least for me ... this.type compared to this._attr.type) regarding isolating data ... i am using object composition here as it made the most sense to me. i dont think there exists a scenario for a AxisLabel without Axis ... or AxisScale without Axis (also no axis without axisscale actually). they are tightly coupled, so i dont see a problem couping them in code as well. also i think object composition fits well here as we are modeling relationship we can describe with HAS-A ... Axis HAS-A AxisScale and Has-A AxisLabels regarding commits i think i am gonna start fresh, with a new PR, which will just ES6ify whole vislib ... we can then start again from there. (maybe even rebase this PR on top of it) |
i created #8186 which converts vislib to use ES6 syntax |
I think that's the right approach, I would just like to see more boundaries between the objects.
In my eyes, the problem with coupling those classes comes with maintenance. But I'm having trouble coming up with a meaningful example. |
- splitting it into 3 subclasses (Axis, AxisLabels, AxisScale) - converting to ES6 classes + style fixes - adding more customization options
- allowing handler to have multiple category/value axes (array)
…f axis - updating css min-widths to 1px (removing them breaks the code) as we dont want to reserve the space for axes that dont exist.
458f317
to
f36da8d
Compare
We're going to move to a more iterative approach and start doing small pull-requests to the vislib-axis-refactor branch, which will culminate in another huge pr like this. |
Update Vislib Axis classes
this PR creates some changes around Vislib.
however none of the features were actually added to kibana. this is just a ground work to make that happen in the future. for now merging this PR should have 0 impact for users, charts should look and feel exactly the same and everything should work exactly the same.
its very possible that options don't work/don't work correctly yet (like setting categoryaxis position to top and yaxis position to right, setting weird fonts and rotations ....) i plan to tackle all that in the future when adding the features to kibana (when i'll have an easy way to check all the possible options kibana offers).
also i updated some other parts of the vislib to use the first axis for now (when you can add multiple). in the future i plan to do some changes to the charts as well to allow using multiple axes and some other things (like having different chart types together (line + bar )
i didn't yet update/write tests, i would first like to get some opinions.
replaces #7961