Fix Mobile Vertical Bar Graph Labels (Closes #50) #83
Loading…
Reference in New Issue
No description provided.
Delete Branch "fix-mobile-bug-labels"
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?
This PR adds the following:
minWidth
minWidth
prop to horizontal and vertical bar graphs, by default, set to 500 (make a PR to contain these default prop values)Note: Everything that is not set to overflow scroll will be cropped (disabled horizontal scrolling in general)
In the future, some other graph components may also need the same support (minimum width + alternating labels)
https://fix-mobile-bug-labels-csc-class-profile-stag-snedadah.k8s.csclub.cloud/
@ -44,2 +44,4 @@
/** Controls the distance between the value axis label and the value axis. */
valueAxisLabelOffset?: number;
/** Minimum width of the graph. Once the graph reaches this value,
* its content will be set to an overflow scroll */
This doesnt actually set it to overflow scroll right? The "isMobile" is what sets it to overflow scroll. (Thats ok, I think its right that the overflow scroll is set by isMobile, just wanted to point out that from my understanding this comment is incorrect)
You're right, this doesn't set the overflow scroll. It's set by
isMobile
.minWidth
only determines when the graph should stop becoming smaller. I'm going to correct this comment. I'm going to do more testing to see if it affects how graphs are viewed in different screens 🤔@ -223,3 +233,3 @@
const categoryMax = width - margin.left - margin.right;
const valueMax = height - margin.top - margin.bottom;
const valueMax = height - margin.top - margin_bottom;
I think there may be a typo here, "margin_bottom"? Did you mean "margin.bottom"
Nope, this is not a typo. Maybe I should have renamed the variables to be clearer 😅.
margin_bottom
is meant to be change the margin.bottom (add extra spacing) if there are alternating labels. See the definition of themargin_bottom
variabe above!@ -311,1 +321,3 @@
tickLabelProps={() => {
tickLabelProps={(value, index) => {
const defaultDy = `-0.25rem`;
const alternatingDy = index % 2 == 0 ? defaultDy : `25px`;
On my phone, the "Slabo 27px" which is two lines overlaps "Raleway". So I think we should maybe increase the spacing a bit more? Furtheremore what would happen if there was a 3 line text in the top row? (Maybe we should provide the spacing as a prop so if needed we can increase the spacing to fit the data if there is a 3 line text)
Also is there a reason for using "rem" in one value, but "px" in the other? We should probably just stick to one.
@snedadah It seems that "rem" are not supported units in SVGs. If you inspect the labels, they are all nested inside of SVGs.
dy
sets they
attribute of the SVGs. So the-0.25rem
surprisingly does nothing 🤔. I'll opt forpx
for now.Otherwise, thanks for noticing! Made these values props to adjust spacing!
@ -38,3 +43,3 @@
{bodyText ? <p>{bodyText}</p> : null}
</div>
<div className={styles.internalWrapper}>{children}</div>
<div className={styles.internalWrapper} style={overflowScroll}>
Is there a reason for not using the already built in media queries here?
I reccomend deleting all these changes here, and instead adding the changes to the css if possilbe. It will look something like this:
Note that you will have to put the default ".interalWrapper" above the @media, since you want the @media .internalWrapper to override the top one.
@ -68,6 +68,7 @@ body {
color: var(--primary-text);
font-family: "Inconsolata", monospace;
margin: 0;
overflow-x: hidden;
The section header at the top "Demographics" still caused my phone to zoom out (basically overflow-x) Just a note that we need to put a media query to fix that.
Nice work! I just made a tiny change in
2051679458
, removing the "nth child" since that is not maintainble, everything else looks good!