-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[charts] Add <ChartsReferenceLine /> component #10597
Conversation
I've updated the PR to use I've kind of removed some features of the |
Deploy preview: https://deploy-preview-10597--material-ui-x.netlify.app/ Updated pages: |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
I can give few examples? |
With pleasure. For consistency, I usually put two examples:
But for now, I would recommend to wait a bit. I'm working on adding the #10138 and its followup wihich might implies a bit more modification 🫣 |
Good.
|
Here I think I have reached something stable. I think it's able to the the same stuff as the initial proposal but with fewer props. <ReferenceLine
label="Example\nwith multi line" // the label to display
x={10} // the reference value
labelAlign="start" // To place the label on the start, middle, or end of the reference line
spacing={10} // the space between the line and the text
lineStyle={{ strokeDasharray: '10 5' }} // Every style customization of the line in a single object
labelStyle={{ strokeColor: 'red' }} // Every style customization of the label in a single object
/> Your example would become <ReferenceLine
- direction="horizontal"
- threshold={100}
+ y={100}
- color="red"
- lineWidth={1}
+ lineStyle={{ strokeWidth: 1, strokeColor: 'red' }}
- text="Limit"
+ label="Limit"
/> I think the was |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
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.
Really nice addition! 💯
Great job! 👍
Leaving some comments for possible improvements and one functional fix that IMHO we should do. 🤔
packages/x-charts/src/ChartsReferenceLine/ChartsXReferenceLine.tsx
Outdated
Show resolved
Hide resolved
packages/x-charts/src/ChartsReferenceLine/ChartsXReferenceLine.tsx
Outdated
Show resolved
Hide resolved
} = props; | ||
|
||
const { top, height } = useDrawingArea(); | ||
const xAxisScale = useXScale(axisId) as any; |
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.
Nitpick: Was a more proper solution considered, which would avoid the need for as any
? 🤔
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 has been more complicated than expected.
Each chart has some expectations about which scale they use, but useXScale
returns any type of scale.
So the next line xAxisScale(x)
was failing because x
could be for example a string (available if using band scale) but the axis scale returned by xAxisScale
could be linear which only accepts number
On the way of experimenting, I structured a bit more the scale types to remove as much any
as possible in scales type def
packages/x-charts/src/ChartsReferenceLine/ChartsXReferenceLine.tsx
Outdated
Show resolved
Hide resolved
packages/x-charts/src/ChartsReferenceLine/ChartsYReferenceLine.tsx
Outdated
Show resolved
Hide resolved
|
||
case 'end': | ||
return { | ||
y: top + height, |
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.
Co-authored-by: Lukas <[email protected]> Signed-off-by: Alexandre Fauquette <[email protected]>
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
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 looks like a really well executed addition. Kudos to everyone involved! 👏 💯
packages/x-charts/src/ChartsReferenceLine/chartsReferenceLineClasses.ts
Outdated
Show resolved
Hide resolved
packages/x-charts/src/ChartsReferenceLine/chartsReferenceLineClasses.ts
Outdated
Show resolved
Hide resolved
packages/x-charts/src/ChartsReferenceLine/chartsReferenceLineClasses.ts
Outdated
Show resolved
Hide resolved
@alexfauquette can we switch the base branch to |
Co-authored-by: alexandre <[email protected]> Co-authored-by: Alexandre Fauquette <[email protected]> Co-authored-by: Lukas <[email protected]>
Co-authored-by: Maxime THOMAS <[email protected]> Co-authored-by: Lukas <[email protected]>
Referencing #10351