Bar Graph Vertical labels on mobile #50
Labels
No Label
Bug
Component
Config
Good First Issue
Low-Priority
Page
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: www/cs-2022-class-profile#50
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
The labels on the bar graph vertical get squished together on mobile.
Maybe we should have them alternate vertically to solve this?
Fix Bar Graph Vertical labels on mobileto [Bug] Bar Graph Vertical labels on mobile[Bug] Bar Graph Vertical labels on mobileto Bar Graph Vertical labels on mobileIdeas discussed during Sept. 7 sitdown:
@e26chiu to investigate these solutions and decide which offers the best balance between appearance and implementation difficulty.
Diagonal Labels Example
The labels are rotated at -45 degrees.
Note: The graph has a certain height which is why it crops part of the label at the bottom. (I was also messing around with
dx
anddy
to position it well visually.A restriction that this implementation may have is the length of the labels which we do not control. Long labels and words can result in overflow. It's also harder to determine the breakpoints to rotate the labels.
Vertical Labels Example
The labels are rotate at 90 degrees. It has a simpler implementation than the previous one:
It suffers from the same problem as the Diagonal Labels example.
Fixed Min-width for graphs && Horizontal scrolls on labels Example
The reason both of these ideas got merged is because they both involve scrolling.
The overflow scroll is implemented by adding this style to the 2nd internal wrapper of the
ComponentWrapper
component:To set a minimum width, I set a constant (that could be added as a prop) of the minimum width a graph should have:
I removed
width
from theconst props
we set at the beginning and set it by itself:This one doesn't have any complications as it preserves the graph at a minimum width where the labels can be clearly displayed (depending on how we set it, we could change the MIN_WIDTH variable depending on the graph we want to display)
Note that certain labels are just long, so they can still overflow.
Alternating labels up/down Example
This one also gets cropped because of the fixed height of the SVG. The use of
rem
doesn't really change how the labels are positioned so I usedpx
instead.Use horizontal graphs (for bars)
We already have horizontal bar graphs.
Conclusion
I think it would be interesting if we use a combination of min width graph + overflow scroll + one of the alternating/rotating labels solutions for the responsive vertical bar graph. The horizontal bar graph is already given (if we want to avoid using vertical bar graphs). We cannot avoid the cropping of the labels if they are rotated or shifted down. To avoid this problem, we can make the SVGs bigger in height then use the container (
ComponentWrapper
) to crop it withoverflow: scroll
.Thanks for the thorough investigation!!!
The way the bar graph is implemented, the bottom margin prop controls the distance between the x-axis and the bottom edge of the entire element - would increasing this value help prevent the labels from getting cut off?
@a258wang Yep! I was able to display some labels that were cropped previously:
Wow, nice investigation!!
I also agree that we should do a combination of min width + overflow scrolling, and either the up/down or diogonal labels.
My only concern with the up down lables is that the down ones seem a bit disconnected.
What do you guys think about adding a line goes up to the bar, something like:
If its too much work don't worry about it, I think it's fine right now, or the diogonal labels also look good to me.