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

Add x-axis spacing options to make them more even #5499

Closed
wants to merge 8 commits into from
Closed

Add x-axis spacing options to make them more even #5499

wants to merge 8 commits into from

Conversation

JamesJansson
Copy link

Currently, spacing on the x-axis is uneven to allow for the final point to be displayed. This change gives two new options:
evenLabelSpacing - ensures even spaces between the labels (possibly ignoring the final point)
labelSpacing - allows the user to choose the space between the labels

@JamesJansson
Copy link
Author

Tests have passed for this improvement. This fixes a recurrent issue that people have complained about regularly.

@benmccann
Copy link
Contributor

people have complained about regularly.

Can you link to the issues?

@JamesJansson
Copy link
Author

e.g.
#4626
#4358

@Hedva
Copy link

Hedva commented Jun 7, 2018

I like it that you didn't forget to update the docs

@JamesJansson
Copy link
Author

No point adding functionality unless people know about it!


var i, tick;

// Specifiy the label spacing
Copy link
Contributor

Choose a reason for hiding this comment

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

Specifiy -> Specify

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

var labelSpacing;
if (optionTicks.labelSpacing) {
labelSpacing = optionTicks.labelSpacing;
// If not an even number, reject
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this restriction? We should mention in the documentation if we keep the restriction

Copy link
Author

Choose a reason for hiding this comment

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

The restriction is because the ticks are integers, updated to say 'integer' instead of 'even number'

Copy link
Member

@etimberg etimberg left a comment

Choose a reason for hiding this comment

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

I think it would be wise to add some tests for this logic. It feels like something that could be easily broken by updates to the scale code

@etimberg etimberg requested a review from simonbrunel July 7, 2018 12:38
var labelSpacing;
if (optionTicks.labelSpacing) {
labelSpacing = optionTicks.labelSpacing;
// If not an integer, reject
Copy link
Contributor

Choose a reason for hiding this comment

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

Either expand the comment here to explain why labelSpacing must be an integer and document the restriction in linear.md or remove the restriction. I'm not sure your assumption that the ticks must be integers is true?

delete tick.label;
}
} else if ((i !== tickCount - 1) && ( // Always show last tick
(skipRatio > 1 && i % skipRatio > 0) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

I would indent this line and the next one more tab so that it doesn't line up with the content inside the curly braces (assuming that doesn't cause the linter to fail)

@benmccann
Copy link
Contributor

Should we really make evenLabelSpacing an option? I would instead say that the current behavior is a bug and we should always apply evenLabelSpacing. Thoughts @simonbrunel @etimberg ?

@@ -12,6 +12,8 @@ The following options are provided by the linear scale. They are all located in
| `min` | `Number` | | User defined minimum number for the scale, overrides minimum value from data. [more...](#axis-range-settings)
| `max` | `Number` | | User defined maximum number for the scale, overrides maximum value from data. [more...](#axis-range-settings)
| `maxTicksLimit` | `Number` | `11` | Maximum number of ticks and gridlines to show.
| `evenLabelSpacing` | `Boolean` | | To be used with `maxTicksLimit`. If true, forces ticks to be evenly spaced, which is different to the default behaviour of unevenly spacing and forcing the display of the final point.
| `labelSpacing` | `Number` | | This setting determines the spacing between labels on the x-axis.
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the difference between labelSpacing and stepSize? Is it that labelSpacing is used exactly whereas a multiple of stepSize may be used? If so, it may be better to reuse stepSize and see if we can do something like autoSkip: false instead

@JamesJansson
Copy link
Author

JamesJansson commented Jul 8, 2018 via email

@benmccann
Copy link
Contributor

@JamesJansson sorry for the slow reply on this. I discussed with Simon. Let's not try to fit the last point. I think the current behavior is a bug and should be changed. We don't need a new option to maintain the old behavior

@JamesJansson
Copy link
Author

So even spacing will become the default behavior? I think that this is best, and will stop a lot of heartache. How/when will the be implemented?

@benmccann
Copy link
Contributor

Would you be able to update this PR to make that change?

@benmccann
Copy link
Contributor

@JamesJansson I wanted to check if you think you'll be able to update this to make even spacing the default

@benmccann
Copy link
Contributor

@JamesJansson do you think you'll be updating this PR? If not, we may close it as inactive, but you're always welcome to reopen it after making the suggested changes. Thanks!

@benmccann
Copy link
Contributor

I'm closing this PR as inactive for now since I haven't gotten any response. Please feel free to reopen after making the suggested changes

@benmccann benmccann closed this Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants