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

Category axis doesn't consider offscreen labels when requesting space #3223

Merged

Conversation

hellochar
Copy link
Contributor

Category Axis will now only render/consider the ticks that will actually be drawn. This fixes a bug where pan/zoomed category axes might have a lot of unnecessary whitespace.

@hellochar hellochar added this to the v3.0.0 milestone Feb 7, 2017
@adidahiya
Copy link
Contributor

screencaps / gifs? is this smooth now?

Copy link
Contributor

@themadcreator themadcreator left a comment

Choose a reason for hiding this comment

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

Just a comment update request

@@ -134,10 +134,10 @@ export class Category extends Axis<string> {
* @param {Scales.Category} scale - The scale being downsampled. Defaults to this Axis' scale.
* @return {DownsampleInfo} an object holding the resultant domain and new stepWidth.
*/
public getDownsampleInfo(scale: Scales.Category = <Scales.Category> this._scale): DownsampleInfo {
public getDownsampleInfo(scale: Scales.Category = <Scales.Category> this._scale, domain = scale.invertRange()): DownsampleInfo {
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't know you could reference previous args in later default args. Neat

@@ -370,7 +367,6 @@ export class Category extends Axis<string> {
// hide ticks and labels that overflow the axis
this._showAllTickMarks();
this._showAllTickLabels();
this._hideOverflowingTickLabels();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we need this anymore?

@@ -50,6 +50,19 @@ export class Category extends Scale<string, number> implements TransformableScal
this._outerPadding = Category._convertToPlottableOuterPadding(0.5, d3InnerPadding);
}

/**
* Return a clone of this category scale without any included values providers.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm glad you're encapsulating this into a method. Can you include in this comment some info about what IS included in the partial "clone" of this scale.

@hellochar
Copy link
Contributor Author

hellochar commented Feb 8, 2017

There's some jank for how this behaves when pan/zoom and downsampling are enabled:

Zoom suddenly stops because the axis grows:

Layout jankily jumps around because the specific labels being drawn (and therefor the height) change while panning:

Thoughts?

@helenkg
Copy link

helenkg commented Feb 8, 2017

@hellochar I would assume once we do vertical labels and truncate them at fixed height, the height of individual labels won't change when zooming and panning?

@adidahiya
Copy link
Contributor

once we do vertical labels and truncate them at fixed height

@helenkg this still won't fix the problem because some labels might be at the full height & truncated while others are not close to the truncation limit

@hellochar in general I'm not a fan of the behavior shown in the above gifs; what if you waited until pan/zoom completed before redrawing the layout?

@hellochar
Copy link
Contributor Author

hellochar commented Feb 8, 2017

@adidahiya not a fan of tying re-compute to panzoom interactions since that adds a lot of complexity. Let me try debouncing requestedSpace() and see how that feels

@adidahiya
Copy link
Contributor

@hellochar can you elaborate on the code complexity just a bit? I think it could work out really well actually from a user's perspective.

Also curious if @pkwi has any thoughts

@hellochar
Copy link
Contributor Author

hellochar commented Feb 8, 2017

throttling doesn't work. Also, with maxWidth and 90 degree angles, it still has some jank:

@pkwi thoughts here?

@blueprint-bot
Copy link

improve comment

Demo: quicktests | fiddle

@hellochar
Copy link
Contributor Author

@adidahiya here's "wait until pan is finished to recalculate":

ezgif com-video-to-gif 9

Definitely feels better. The zoom issue is still there but I think I'm okay with leaving that in until people complain.

…-labels

Conflicts:
	package.json
	plottable.js
@blueprint-bot
Copy link

Merge branch 'develop' into xzhang/axis-should-not-consider-offscreen-labels

Demo: quicktests | fiddle

@themadcreator
Copy link
Contributor

Okay, i think i finally get how this works. I was just missing the fact that your pass in the value of .invertRange() as the domain. Looks good, and this should work really well with sheared ticks

@themadcreator
Copy link
Contributor

I'm gonna merge this because I want to pull these changes in to test sheared ticks. If there are still more changes to address the "jank", that can be a followup PR

@themadcreator themadcreator merged commit 83eb42c into develop Feb 10, 2017
@themadcreator themadcreator deleted the xzhang/axis-should-not-consider-offscreen-labels branch February 10, 2017 20:41
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

5 participants