Reset a plot's zoom only?

I am trying to find a way to have the reset tool reset the plot zoom level only, without clearing the selection.

This behavior is controlled by plot_canvas.ts:

  reset(): void {
    if (this.model.reset_policy == "standard") {
    this.model.trigger_event(new Reset())

So it seems what I want to do is set the plot’s reset policy to event_only and then from e.g. a Reset event callback, call reset_range() on the plot_canvas directly. However, it’s not at all clear if/how I can access the plot_canvas from the plot object accessible to the js callbacks.

There seems to be no other straightforward way to reset a plot’s x and y ranges, unless I am missing something? I suppose you could set the start and end of each range to the values in bounds, though that’s a bit tedious.

Ah actually, resetting the range’s start and end values to the values stored in its bounds array does not work for ranges that calculate their bounds automatically: there’s no guarantee that those bounds have been properly recalculated at the time of the reset event, and there’s no way to ask the range to recalculate its’ bounds in javascript AFAICT.

So it appears that there’s no way from javascript to ask a plot to reset its range in an auto-bounding fashion, aside from replicating the entire calculation (including checking based on visibility etc.) in a js callback.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.