-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[charts-pro] Add a borderRadius
property to FunnelChart
#17660
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
Conversation
@@ -20,6 +20,11 @@ export interface FunnelPlotProps extends FunnelPlotSlotExtension { | |||
* @default 0 | |||
*/ | |||
gap?: number; | |||
/** | |||
* The radius, in pixels, of the corners of the funnel sections. | |||
* @default 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.
@noraleonte Should we make the default >0? Maybe also the gap? The funnel with border radius look quite nice to me 😄
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, I think we should. We can make it an 8 by default for a softer look 💙
Deploy preview: https://deploy-preview-17660--material-ui-x.netlify.app/ Updated pages: |
borderRadius
property to FunnelChart
borderRadius
property to FunnelChart
CodSpeed Performance ReportMerging #17660 will not alter performanceComparing Summary
|
Co-authored-by: Bernardo Belchior <[email protected]> Signed-off-by: Jose C Quintas Jr <[email protected]>
Not exactly about the borderRadius, but I missed the PR about gap The math are correct, but it feels weird. For mee slices seems to be disconnected. A solution I found is to do an average between the correct position and the one if we ignored the gap. const xGap = point.x + (index === 0 || index === 3 ? this.gap : -this.gap);
return {
- y: yGetter(xGap),
+ y: yGetter((point.x + xGap) / 2), The reason why it looks better to me is the alignment. With their current placement, the slices join in the middle of the gap, and my brain is not evolved enough to notice when lines cross a middle point. I also noticed that doing the opposite (making the larges item align on the smaller one) seems weird too. I went with an average, but that's impact somewhat the link between data and visualisation. A simpler solution is to tweak params you pass to your interpolator as follow:
The idea is to modify the interpolator such that bottom points are the one actually drawn by the chart, but to point are targeting the one of the previous item: Playing with those let me notice what's probably an error in slope start/end: - const slopeStart = this.points.at(index <= 1 ? 0 : 2)!;
+ const slopeStart = this.points.at(index <= 1 ? 0 : 3)!;
- const slopeEnd = this.points.at(index <= 1 ? 1 : 3)!;
+ const slopeStart = this.points.at(index <= 1 ? 0 : 3)!; OtherBy the way, I'm not a big fan of the fact that |
Will try this out. This will probably only affect this curve 🤔, so might be ok to do. I have
Why would the original be wrong? Points are:
So slopes are always 0-1 and 2-3 no?
Yeah, I couldn't offset that easily. Gap uses pixel, while the |
Pyramids aren't an issue because they all align on the same line :)
There is a mistake in my But the current implementation is
Always starting from the larger to smaller edge. By the way If you can make your ASCII scheme in the codebase that would be nice :) |
Doesn't seem like it affects the output of the graph |
I'm not sure where to put it, since it is true for all funnel curves |
Try the following interpolation ;) xFromY(
slopeStart.x,
slopeStart.y - this.gap,
slopeEnd.x,
slopeEnd.y - 10 * this.gap,
); |
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 the previous funnel chart looked better (Argos). Here's the current state:
The imaginary line connecting the 180 section to the 200 section doesn't seem to line up, which looks a bit weird to me 🤔
Previously, I think it looked better:
If it's just me, it's fine to go ahead with this PR.
const getBorderRadius = () => { | ||
if (this.gap > 0) { | ||
return this.borderRadius; | ||
} | ||
} | ||
if (this.position === 0) { | ||
return [0, 0, this.borderRadius, this.borderRadius]; | ||
} | ||
if (this.position === this.sections - 1) { | ||
return [this.borderRadius, this.borderRadius]; | ||
} | ||
return 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.
Should we move this to a private class method? It doesn't reference any variable in scope.
}); | ||
|
||
// Add gaps where they are needed. | ||
this.points = this.points.map((point, index) => { |
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.
}); | |
// Add gaps where they are needed. | |
this.points = this.points.map((point, index) => { | |
}).map((point, index) => { | |
// Add gaps where they are needed. |
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 prefer to leave it above the var assignment rather than in the fn
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.
Not a deal breaker, but seems weird to me that we're assigning a variable just to re-assign it later.
packages/x-charts-pro/src/FunnelChart/curves/borderRadiusPolygon.ts
Outdated
Show resolved
Hide resolved
I think both look ok. I might prefer the original, but I have also been looking at these for a long time 🤔 |
Now that I look at it with the border radius, it looks much better. Looks good to me 👍 |
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 job 👍
borderRadius
property toFunnelChart
FunnelStep
curve toStep
. It technically can handle any 4 point shape.Changelog
Add a
borderRadius
property toFunnelChart
. All funnels have a8px
borderRadius
by default