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

note start/end of interactive periods on document #7143

Merged
merged 1 commit into from Nov 7, 2017

Conversation

bryevdv
Copy link
Member

@bryevdv bryevdv commented Oct 31, 2017

This PR adds support for "linked" LOD by making the document centrally responsible to note the start/end/duration of interactive periods. This simplifies the code at the point of usage and allows for some simple unit tests to be added.

With this work, LOD start/end events are only triggered on the plot that originated the interactive period.

Here is an example script that can be used:

import numpy as np

from bokeh.plotting import figure, show, output_file
from bokeh.layouts import row

N = 4000
x = np.random.random(size=N) * 100
y = np.random.random(size=N) * 100
radii = np.random.random(size=N) * 1.5
colors = [
    "#%02x%02x%02x" % (int(r), int(g), 150) for r, g in zip(50+2*x, 30+2*y)
]

p0 = figure()

p0.scatter(x, y, radius=radii,
          fill_color=colors, fill_alpha=0.6,
          line_color=None)

x = np.random.random(size=N) * 100
y = np.random.random(size=N) * 100
radii = np.random.random(size=N) * 1.5
colors = [
    "#%02x%02x%02x" % (int(r), int(g), 150) for r, g in zip(50+2*x, 30+2*y)
]

p1 = figure(x_range=p0.x_range, y_range=p0.y_range)

p1.scatter(x, y, radius=radii,
          fill_color=colors, fill_alpha=0.6,
          line_color=None)

output_file("color_scatter.html", title="color_scatter.py example")

show(row(p0, p1))  # open a browser

There are further refinements that could be made in the future. In particular the same simple LOD threshold applies for all plots but this is not always ideal. In particular default settings do not trigger LOD on the second plot in the vector.py example, because the data size for the multi_line is small (92) even though the total number of points that make up those lines is much larger.

@bryevdv
Copy link
Member Author

bryevdv commented Nov 1, 2017

This is seeming to fail due to two JS examples not working? Not sure what's going on there yet.

@bryevdv
Copy link
Member Author

bryevdv commented Nov 1, 2017

Also three JS tests I thought were passing I had accidentally just commented out. Some problem with sinon/spy but I have not been able to to figure it out. @mattpap if nothing jumps out at you we can just close this PR and reject the issue with wontfix it's not that important.

@mattpap
Copy link
Contributor

mattpap commented Nov 1, 2017

@bryevdv, gulp examples fails to compile. I see this is in other PRs as well, so it's unrelated. TypeScript 2.6 was released yesterday, so I presume this is the reason. I will fix this in the morning.

@bryevdv
Copy link
Member Author

bryevdv commented Nov 6, 2017

OK I believe I found the issue, the mocks for trigger_event were expecting calledOnce to be true, but it's not. However, called is true, and I believe this is correct. In addition to the actual UI event, e.g. pan or wheel, there is also LODStart. So I think it should expect more than one call, which is what the test now reflects.

@bryevdv
Copy link
Member Author

bryevdv commented Nov 6, 2017

This should be pretty uncontroversial I will merge in the morning and cut a dev build unless there is comment.

@bryevdv bryevdv merged commit 9631761 into master Nov 7, 2017
@bryevdv bryevdv deleted the bryanv/5937_linked_lod branch November 7, 2017 16:14
@_interactive_timestamp = Date.now()

interactive_stop: (plot) ->
if @_interactive_plot?.id == plot.id
Copy link
Contributor

Choose a reason for hiding this comment

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

@bryevdv, what's the reason for comparing ids instead of just references (@_interactive_plot == plot)?

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.

LOD in linked plots
2 participants