-
Notifications
You must be signed in to change notification settings - Fork 26
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
Updates to bindings for XYZ axes, Treemap, Pie, and Cell components #59
Conversation
Before I intro some breaking changes, I want to ensure that they are the best possible changes I can so I'm making this a draft as I iterate some more on these. |
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.
Looking good to me.
) => | ||
makeProps( | ||
~interval=?interval |> AxisInterval.encodeOpt, | ||
~onClick=? |
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.
It already had the runtime on it with interval |> AxisInterval.encodeOpt
here so I figured it was ok but I can rip these out.
I included them mostly to help upgrading since you'd have to rewrite all of the functions to be uncurried otherwise but since these have breaking changes in them anyways maybe that's ok?
src/ZAxis.re
Outdated
@@ -10,7 +10,7 @@ external make: | |||
~allowDuplicatedCategory: bool=?, | |||
~axisLine: 'axisLine=?, | |||
~className: string=?, | |||
~dataKey: string=?, | |||
~dataKey: 'dataKey=?, |
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 other types can be dataKey
? Is it really anything? Is it worth documenting + including a link to official docs if they exist?
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 is why I put this back into draft actually.
I've been hitting a lot of bindings here that are marked as anything but they really aren't so I've been replacing them with [@mel.unwrap]
versions in my local copy and I'll update this PR when I have that in a good spot and confirmed they are all indeed working as intended.
@jchavarri I updated the PR with more correct bindings for the XYZ axes. |
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.
Nice! I tried to check some bindings against the official docs but they just say Function
so 🤷
CHANGES.md
Outdated
- change `axisLine` type from `any` to `[ | `Bool(bool) | `Obj(Js.t({..}))]` in `XAxis`, `YAxis`, and `ZAxis` | ||
- change `dataKey` type from `string` to `[ | `Str(string) | `Int(int) | `Fn('dataObj => 'dataKey)]` in `XAxis`, `YAxis`, and `ZAxis` | ||
- change `label` type from `any` to `[ | `Str(string) | `Int(int) | `Float(float) | `Component(React.element) | `Obj(Js.t({..}))]` in `XAxis`, `YAxis`, and `ZAxis` | ||
- change `name` type from `string` to `[ | `Str(string) | `Int(int) | `Float(float)]` in `XAxis`, `YAxis`, and `ZAxis` | ||
- add `range` prop to `XAxis` and `YAxis` | ||
- change `tick` type from `any` to `[ | `Obj(Js.t({..})) | `Component(React.element) | `Bool(bool) | `Fn('tick => React.element)]` in `XAxis`, `YAxis`, and `ZAxis` | ||
- change `tickFormatter` type from `any` to `(. 'tick, int) => string` in `XAxis`, `YAxis`, and `ZAxis` and wrap it with a curried function | ||
- change `tickLine` type from `any` to `[ | `Bool(bool) | `Obj(Js.t({..}))]` in `XAxis`, `YAxis`, and `ZAxis` | ||
- change `tickSize` type from `float` to `[ | `Float(float) | `Int(int)]` in `XAxis`, `YAxis`, and `ZAxis` | ||
- fix curried functions in event handlers for `XAxis`, `YAxis`, and `ZAxis` | ||
- add `transform` and `stroke` props to `XAxis`, `YAxis`, and `ZAxis` | ||
- add `style` prop to `ZAxis` | ||
- add `fillOpacity` prop to `Cell` | ||
- add optional flags to `Treemap` props `stroke`, `fill`, `isAnimationActive`, `animationDuration` | ||
- wrap `Pie` event handlers data prop in `Js.Nullable.t` |
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.
Maybe we can add something along the lines of the PR description in one line ("Improve bindings for XYZ axes, Treemap, Pie and Cell components"), with a link to the PR for those interested on details.
I would also add "Breaking" before it.
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.
Done
[@mel.unwrap] [ | ||
| `Bool(bool) | ||
| `Obj(Js.t({..})) |
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.
Nice!
~unit: string=?, | ||
~width: int=?, | ||
~yAxisId: string=? |
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.
Was this a typo?
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.
https://recharts.org/en-US/api/ZAxis#zAxisId
It might have been a typo before but should be correct now
src/YAxis.re
Outdated
| `Str(string) | ||
| `Int(int) | ||
| `Float(float) | ||
| `Component(React.element) |
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'd call this Element
. (A component is what creates elements, aka the make
function). Same for other usages in other modules.
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.
Done
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.
Ah... I remember now that I named it that to be consistent with this. I feel like I should also update this as well.
~domain: array('domain)=?, | ||
~height: int=?, | ||
~hide: bool=?, | ||
~interval: AxisInterval.t=?, | ||
~label: 'label=?, | ||
~label: | ||
[@mel.unwrap] [ |
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.
Should we maybe replace some of those types in Utils
with mel.unwrap
too?
https://github.com/ahrefs/melange-recharts/blob/master/src/Utils.re#L135
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'd like to tackle this in another PR but I think this is a great suggestion.
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.
PR open: #60
Yeah I had to do a lot of diving into the repo and runtime testing to figure these out 🫠 |
@jchavarri I left this marked as |
This does include 2 breaking changes:
tickSize
is now a float instead of an int since ticks do not have to be whole numbersPie
the first arg which is the data that is coming into the event is nullableI thought I'd group these breaking changes together so that a single release could be cut but I can split things apart if needed.
Summary of changes:
XAxis
,YAxis
, andZAxis
dataKey
type fromstring
to'dataKey
inXAxis
,YAxis
, andZAxis
tickSize
type fromint
tofloat
inXAxis
,YAxis
, andZAxis
transform
andstroke
props toXAxis
,YAxis
, andZAxis
style
prop toZAxis
fillOpacity
prop toCell
Treemap
propsstroke
,fill
,isAnimationActive
,animationDuration
Pie
event handlers data prop inJs.Nullable.t