Line Graph Component using curve #47
Labels
No Label
Bug
Component
Config
Good First Issue
Low-Priority
Page
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: www/cs-2022-class-profile#47
Loading…
Reference in New Issue
No description provided.
Delete Branch "b72zhou-line-graph-v2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
https://b72zhou-line-graph-v2-csc-class-profile-staging-snedadah.k8s.csclub.cloud/
WIP: Line Graph Component using curveto Line Graph Component using curveThis actually looks so good, thank you Beihao for working on it! Just left some small questions and nitpicks 🙂
@ -0,0 +122,4 @@
const yScale = scaleLinear<number>({
range: [0, yMax],
nice: true,
domain: [100, 0],
This should probably be
[<maxYValue>, 0]
in case we go above 100 (eg. if we aren't doing percentages)@ -0,0 +142,4 @@
<GridRows
scale={yScale}
width={xMax}
left={margin.left * 2}
Since everything is already inside the
Group
withtop={margin.top} left={margin.left}
, I'm not sure if you still need to set all the margins on the components since they should be positioned relative to theGroup
.In particular, I noticed that the horizontal grid lines stick out a little bit on each side, when they should ideally not stick out past the vertical lines on both ends. Hopefully this is possible!
oh the reason why I still set margins on components is to stick out past the vertical lines on both ends lol. So I think we may still need the margin and I adjusted the margin a bit more to make it look better
@ -0,0 +183,4 @@
/>
<Group left={margin.left + xMax / (data.xValues.length * 2)}>
{actualData.map((lineData, i) => {
const even = i % 2 === 0;
NIT: some people prefer to name booleans
isEven
etc.@ -0,0 +205,4 @@
data={lineData}
className={styles.line}
x={(d) => xScale(getX(d)) ?? 0}
y={(d) => yScale(getY(d)) ?? 0}
These can probably just be
getX(d)!
etc. instead of ??I tried but it says non-null assertion is forbidden. Do we have any other ideas?
Use
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
We should probably disable this lint rule globally, but the comment should be good enough for now.
@ -0,0 +207,4 @@
x={(d) => xScale(getX(d)) ?? 0}
y={(d) => yScale(getY(d)) ?? 0}
stroke={even ? Color.primaryAccent : Color.secondaryAccent}
strokeWidth={3}
How does it look with
strokeWidth={4}
? I just think it's a little funny that the gridlines are thicker than the actual chart lines. 😂@ -0,0 +218,4 @@
</svg>
{tooltipOpen && (
<TooltipInPortal
I'm curious, what's the difference between
Tooltip
vs.TooltipInPortal
? Just asking because I saw everyone else using Tooltip. XDThe documentation for
TooltipInPortal
says:Since I met problems with hover effect before, it seems this might help if I met similar problems again. But actually everything goes well this time and the feature for portal is not used. XD
@ -0,0 +219,4 @@
{tooltipOpen && (
<TooltipInPortal
// set this to random so it correctly updates with parent bounds
this comment seems outdated 🤔
@ -67,1 +67,4 @@
export const mockLineData = {
xValues: ["1A", "1B", "2A", "2B", "3A", "3B"],
lines: [
Maybe we should throw an error in the LineGraph component if the number of xValues and number of yValues don't match?
@ -70,0 +82,4 @@
left: 40,
right: 20,
}}
></LineGraph>
NIT:
<LineGraph />
@a258wang I feel that the staging doesn't work... Could you please
npm run dev
locally and see if we can merge this component? Thanks!