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

delay match_aspect adjustment #7342

Merged
merged 4 commits into from
Dec 26, 2017
Merged

delay match_aspect adjustment #7342

merged 4 commits into from
Dec 26, 2017

Conversation

bryevdv
Copy link
Member

@bryevdv bryevdv commented Dec 21, 2017

The commit moves the aspect ratio adjust (for a single plot update) to after the unioned bounds are computed for the DataRange renderers. Previously the aspect correction happened on all the individual renderer bounds, before the call to update. This could result in incorrect aspect-corrected overall bounds in some situations.

Note: use of match_aspect with linked DataRange1d across multiple plots will probably yield undefined/undesirable behavior and should be considered unsupported.

@bryevdv
Copy link
Member Author

bryevdv commented Dec 21, 2017

Want to see how CI report looks, do additional local testing, and update docs to warn about match_aspect usage with linked data ranges.

@@ -216,43 +216,24 @@ export class PlotCanvasView extends DOMView
follow_enabled = false
has_bounds = false

unioned_bounds =

r = null
if @model.plot.match_aspect != false and @frame._width.value != 0 and @frame._height.value != 0
r = 1/@model.plot.aspect_scale*(@frame._width.value/@frame._height.value)
Copy link
Member Author

Choose a reason for hiding this comment

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

@mattpap Is there a better way to do this / communicate an optional ratio to the subsequent calls to update below?

@bryevdv
Copy link
Member Author

bryevdv commented Dec 21, 2017

With this change the original issue code looks as expected:

screen shot 2017-12-21 at 12 33 21

@@ -216,43 +216,22 @@ export class PlotCanvasView extends DOMView
follow_enabled = false
has_bounds = false

r = null
Copy link
Member Author

Choose a reason for hiding this comment

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

@mattpap is there a better way to subsequently communicate this optional value to update ?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, this is idiomatic javascript.

this._plot_bounds[bounds_id] = this._compute_plot_bounds(renderers, bounds)
let total_bounds = this._compute_plot_bounds(renderers, bounds)

if (r != null)
Copy link
Contributor

Choose a reason for hiding this comment

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

This should have resulted in an error, because r is a number, not number | null (or similar), but apparently it compiles. Looks like another bug in the compiler. Anyway, given r optional nature, the signature of this method should be changed to r?: number. I would also change r to something more meaningful (ratio, aspect_ratio).

@@ -93,6 +93,32 @@ export class DataRange1d extends DataRange {
return result
}

adjust_bounds_for_aspect(bounds: Rect, r: number) : Rect {
let result = bbox.empty()
Copy link
Contributor

Choose a reason for hiding this comment

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

const.

@@ -93,6 +93,32 @@ export class DataRange1d extends DataRange {
return result
}

adjust_bounds_for_aspect(bounds: Rect, r: number) : Rect {
Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace.

The commit moves the aspect ratio adjust (for a single plot update) to
after the unioned bounds are computed for the DataRange rendereres.
Previously the aspect correction happened on all the individual renderer
bounds, before the call to update. This could result in incorrect
aspect-corrected overall bounds in some situations.

Note: use of match_aspect with linked DataRange1d across multiple plots
will probably yield undefined/undesirable behaviour and should be
considered unsupported.
@bryevdv bryevdv merged commit f3ced4b into master Dec 26, 2017
@bryevdv bryevdv deleted the bryanv/7218_circles branch December 26, 2017 23:00
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.

circle not circular
2 participants