Skip to content
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

Population graph layout issue with very long strings #210

Closed
ariel-phet opened this issue Aug 28, 2020 · 9 comments
Closed

Population graph layout issue with very long strings #210

ariel-phet opened this issue Aug 28, 2020 · 9 comments
Assignees

Comments

@ariel-phet
Copy link

Discovered while performing string tests for phetsims/qa#539

With very long strings the population graph (but not the pedigree or proportion graph) gets very messed up in layout

I suspect there is something going on with the "generations" string on the bottom of the graph.

The sim passed all string tests, but this was noticed during ?stringTest=xss (but passes for ?stringTest=long

Although not a showstopper for the first release, this is probably good to fix for iO since a long string could potentially be put in place by an instructional designer

To reproduce:

  1. Go to https://phet-dev.colorado.edu/html/natural-selection/1.1.0-dev.18/phet/natural-selection_all_phet.html?stringTest=xss

stringNs

@pixelzoom
Copy link
Contributor

pixelzoom commented Aug 28, 2020

Agree that this can be deferred for the prototype.

I thought this might be a problem with the string that stringTest=xss uses, so I tried doubling up the stringTest=long string, i.e.:

?stringTest=1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890

... and the result was:

screenshot_528

So as the string gets longer, the Population graph is getting pushed more to the right.

This also indicates that the current stringTest=long may be insufficient (issue phetsims/chipper#976 created.)

@pixelzoom
Copy link
Contributor

Note to self... Testing with stringTest=xss is part of the CRC, and I recently completed a self code review. I know that I tested with xss, but I don't recall seeing this problem -- maybe I was just looking for a redirect. In any case, test with a dev version from around that time, to see if this is something that snuck in recently.

@pixelzoom
Copy link
Contributor

This problem first appears in 1.1.0-dev.4. 1.1.0-dev.3 was published 2020-08-03 19:47. 1.1.0-dev.4 was published 2020-08-10 13:42. I suspect that it's related to the "Zoom in to see data" string, which may not have a maxWidth set.

@pixelzoom
Copy link
Contributor

pixelzoom commented Aug 28, 2020

Making the "Zoom to see data" string visible at all times confirms the problem, screenshot below. And looking at the code in PopulationGraphNode.js, I neglected to set a maxWidth:

    const zoomOutToSeeDataText = new Text( naturalSelectionStrings.zoomOutToSeeData, {
      font: NaturalSelectionConstants.INSTRUCTIONS_FONT,
      centerX: gridNode.x + gridWidth / 2,
      centerY: gridNode.y + gridHeight / 2
    } );

screenshot_529

@pixelzoom
Copy link
Contributor

pixelzoom commented Aug 28, 2020

Here's a 1-line patch that fixes the problem. I'm going to wait to commit this until we decide when this issue should be addressed.

patch
Index: js/common/view/population/PopulationGraphNode.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- js/common/view/population/PopulationGraphNode.js	(revision 4b4266ed8b81d55958056710a5e8d8b8b75d9fec)
+++ js/common/view/population/PopulationGraphNode.js	(date 1598582041505)
@@ -116,6 +116,7 @@
 
     const zoomOutToSeeDataText = new Text( naturalSelectionStrings.zoomOutToSeeData, {
       font: NaturalSelectionConstants.INSTRUCTIONS_FONT,
+      maxWidth: 0.75 * gridWidth,
       centerX: gridNode.x + gridWidth / 2,
       centerY: gridNode.y + gridHeight / 2
     } );

@pixelzoom
Copy link
Contributor

pixelzoom commented Aug 28, 2020

This fix is almost zero risk. I recommend that we roll this fix into the prototype RC, and @ariel-phet approves.

@pixelzoom
Copy link
Contributor

pixelzoom commented Aug 28, 2020

Fixed in the above commit and ready for verification.

To verify in 1.1.0-rc.1:

  1. Run the sim with ?stringTest=xss
  2. Go to either screen
  3. Verify that the layout looks correct, and in particular does not look like the screenshot in Population graph layout issue with very long strings #210 (comment)

@amanda-phet
Copy link
Contributor

Checked this out on the iPad and it looks good. I also made sure the "zoom in.." text showed up and it still looked good.

@amanda-phet amanda-phet removed their assignment Aug 28, 2020
@ariel-phet
Copy link
Author

Looks good, checked as phetsims/qa#540

Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants