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

Change step grid #181

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Change step grid #181

wants to merge 4 commits into from

Conversation

samuel-stahl
Copy link
Contributor

@samuel-stahl samuel-stahl commented Jun 18, 2021

Description

This PR adds a new dropdown to the top menu, Grid, which allows the user to change the grid size. However, there are some issues I would like to address, both on my end and in general.

Addresses issue #62

Problems

  1. I have not yet changed the coordinate rounding function. Could someone tells me where it is called so I can figure out how best to change it?
  2. The old logic for horizontal grid generation explicitly avoided generating grid lines on yard lines unless the yard lines were removed. However, to make it easier to extend to 1-step and 4-step grids, I changed the logic to resemble the vertical lines, and therefore redundantly generates grid lines on top of yardlines. Should we strive to keep gridline generation non-redundant, or would it be easier in the long run to keep it as I have it? For reference, the old X-Offset function is present, but commented out.
  3. Due to the dimensions of the field, the 4 Step grid leaves a small horizontal space at the bottom of the field. Should we keep 4 Step grid generation as is, or should we change it somehow?

Pre-PR checklist

  • Ran npm run serve and:
    • Checked basic functionality
    • Checked that errors are handled
  • Ran npm run lint
  • Ran npm run test:unit
  • Ran npm run test:e2e and ran relevant tests
  • Attached reviewers to PR and pinged on Slack/email

Screenshots/GIFs

grid-size-1
grid-size-2
grid-size-4

@samuel-stahl samuel-stahl requested review from rmpowell77, MichaelTamaki and adhamrait and removed request for rmpowell77 and MichaelTamaki June 18, 2021 05:49
@samuel-stahl samuel-stahl marked this pull request as draft June 18, 2021 06:31
Copy link
Collaborator

@MichaelTamaki MichaelTamaki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Left some suggestions for you. And here's some comments on the questions you brought up

I have not yet changed the coordinate rounding function. Could someone tells me where it is called so I can figure out how best to change it?

Are you referring to BaseTool:roundCoordinateToGrid? https://github.com/calband/calchart-redesign/blob/main/src/tools/BaseTool.ts#L19

The old logic for horizontal grid generation explicitly avoided generating grid lines on yard lines unless the yard lines were removed. However, to make it easier to extend to 1-step and 4-step grids, I changed the logic to resemble the vertical lines, and therefore redundantly generates grid lines on top of yardlines. Should we strive to keep gridline generation non-redundant, or would it be easier in the long run to keep it as I have it? For reference, the old X-Offset function is present, but commented out.

This is fine, a couple of additional lines for the grid won't hurt! Honestly it was a performance optimization that wasn't really needed. The browser can handle thousands of SVG elements.

Due to the dimensions of the field, the 4 Step grid leaves a small horizontal space at the bottom of the field. Should we keep 4 Step grid generation as is, or should we change it somehow?

(Note that this is actually an 8 step grid that you are referring to) Great catch! This is fine, it's bound to happen... We could consider doing a grid offset? Like make the grid start from a different Y position (like -4 shifts the grid up 4 steps)? Let's create an issue for that just to keep that on our backlog.

// retVal.push(offsetX);
// }
// return retVal;
// },
fourStepGridOffsetsX(): number[] {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename this and fourStepGridOffsetsY to something more generic

Comment on lines 143 to 145
let offsetX = gridSize * 2;
offsetX < this.fieldWidth;
offsetX += gridSize * 2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to multiply by 2 here, the X/Y scale should be 1 spacing unit to 1 step. Notice in the screenshots that the 4 step grid is actually an 8 step grid (there should be a vertical line in between each line yard, since each line yard is 8 steps between each other).

Comment on lines +72 to +91
<b-navbar-dropdown label="Grid" data-test="menu-top--grid">
<b-navbar-item
data-test="menu-top--grid-one"
@click="changeStepGrid(1)"
>
One Step
</b-navbar-item>
<b-navbar-item
data-test="menu-top--grid-two"
@click="changeStepGrid(2)"
>
Two Step
</b-navbar-item>
<b-navbar-item
data-test="menu-top--grid-four"
@click="changeStepGrid(4)"
>
Four Step
</b-navbar-item>
</b-navbar-dropdown>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works okay, but I don't think this should be it's own top navbar item. We should reserve creating a new dropdown at the top level for new categories (For example, see the top menu of any program you use, "File", "Edit", "View", "Help", etc.)

Let's consider other options... How about the bottom menu next to all the tool icons?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there is a way to get some tiered/tree menus in Buefy. I'm thinking something like the Format -> Number selection in google sheets. That way we can put it in the view section...

image

@@ -40,6 +40,8 @@ export class CalChartState extends Serializable<CalChartState> {

showDotLabels = true;

gridSize = 2;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the x2 comment is resolved in GrapherField, let's update this

Suggested change
gridSize = 2;
gridSize = 4;

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

Successfully merging this pull request may close these issues.

None yet

3 participants