Unable to update plot_width using update function

Hi,

I’m trying to make a plot that the plot width and x axis tick labels change with the values from two widget input: to_date and from_date. Now the x axis ticker labels and printed p.plot_width value change as the dates change, but the plot width does not update to the plot.

My code looks like below:

p = Figure(plot_height=600)

# configure x axis
p.x_range = FactorRange()
p.xaxis[0].formatter = DatetimeTickFormatter(formats=dict(
    hours=["%Y-%m-%d"],
    days=["%Y-%m-%d"],
    months=["%Y-%m-%d"],
    years=["%Y-%m-%d"],
))

source = ColumnDataSource(data=dict(x=[], y=[]))
r = p.circle(x='x', y='y', source=source)
from_date = TextInput(value='2016-03-01',
                      title='Please enter the starting date in the format of yyyy-mm-dd')
to_date = TextInput(value='2016-04-30',
                    title='Please enter the ending date in the format of yyyy-mm-dd')

def update(attr, old, new):

d_range = pd.date_range(from_date.value.strip(), to_date.value.strip()).strftime(’%Y-%m-%d’)

p.plot_width = 25 + len(d_range) * 65 + 25
  print(p.plot_width)
p.x_range.factors = d_range.tolist()
  p.xaxis[0].ticker = CategoricalTicker(tags=d_range.tolist())
  p.xgrid[0].ticker = CategoricalTicker(tags=d_range.tolist())

ds2.data = dict(…)

from_date.on_change('value', update_plot)
to_date.on_change('value', update_plot)

controls = [from_date, to_date]
w_box = widgetbox(controls, width=200, sizing_mode='fixed')
# page_layout = row(w_box, p)
page_layout = layout(children=[[w_box, p]])
curdoc().add_root(page_layout)

Many thanks in advance!
Caroline

Caroline,

I don't think that the `plot_width` and `plot_height` values are used beyond initialization, so this may not be possible at the moment. It will require some looking into. I'd suggest opening a GH issue with this code to discuss and investigate further.

Thanks,

Bryan

···

On Jun 29, 2016, at 3:00 PM, [email protected] wrote:

Hi,

I'm trying to make a plot that the plot width and x axis tick labels change with the values from two widget input: to_date and from_date. Now the x axis ticker labels and printed p.plot_width value change as the dates change, but the plot width does not update to the plot.

My code looks like below:

p = Figure(plot_height=600)
# configure x axis
p.x_range = FactorRange()
p.xaxis[0].formatter = DatetimeTickFormatter(formats=dict(
    hours=["%Y-%m-%d"],
    days=["%Y-%m-%d"],
    months=["%Y-%m-%d"],
    years=["%Y-%m-%d"],
))

source = ColumnDataSource(data=dict(x=, y=))
r = p.circle(x='x', y='y', source=source)

from_date = TextInput(value='2016-03-01',
                      title='Please enter the starting date in the format of yyyy-mm-dd')
to_date = TextInput(value='2016-04-30',
                    title='Please enter the ending date in the format of yyyy-mm-dd')

def update(attr, old, new):
    d_range = pd.date_range(from_date.value.strip(), to_date.value.strip()).strftime('%Y-%m-%d')
  p.plot_width = 25 + len(d_range) * 65 + 25
  print(p.plot_width)
  p.x_range.factors = d_range.tolist()
  p.xaxis[0].ticker = CategoricalTicker(tags=d_range.tolist())
  p.xgrid[0].ticker = CategoricalTicker(tags=d_range.tolist())
  ds2.data = dict(...)

from_date.on_change('value', update_plot)
to_date.on_change('value', update_plot)

controls = [from_date, to_date]
w_box = widgetbox(controls, width=200, sizing_mode='fixed')
# page_layout = row(w_box, p)
page_layout = layout(children=[[w_box, p]])
curdoc().add_root(page_layout)

Many thanks in advance!
Caroline

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9613c0e7-7bf6-4c87-b2fc-5fd95ca22756%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Hi Bryan,

It was possible in 0.11 as I tried before. Is there any workaround I can use to make the plot width updatable?

Thank you!

Caroline

···

On Wednesday, June 29, 2016 at 1:45:40 PM UTC-7, Bryan Van de ven wrote:

Caroline,

I don’t think that the plot_width and plot_height values are used beyond initialization, so this may not be possible at the moment. It will require some looking into. I’d suggest opening a GH issue with this code to discuss and investigate further.

Thanks,

Bryan

On Jun 29, 2016, at 3:00 PM, [email protected] wrote:

Hi,

I’m trying to make a plot that the plot width and x axis tick labels change with the values from two widget input: to_date and from_date. Now the x axis ticker labels and printed p.plot_width value change as the dates change, but the plot width does not update to the plot.

My code looks like below:

p = Figure(plot_height=600)

configure x axis

p.x_range = FactorRange()

p.xaxis[0].formatter = DatetimeTickFormatter(formats=dict(

hours=["%Y-%m-%d"],
days=["%Y-%m-%d"],
months=["%Y-%m-%d"],
years=["%Y-%m-%d"],

))

source = ColumnDataSource(data=dict(x=, y=))

r = p.circle(x=‘x’, y=‘y’, source=source)

from_date = TextInput(value=‘2016-03-01’,

                  title='Please enter the starting date in the format of yyyy-mm-dd')

to_date = TextInput(value=‘2016-04-30’,

                title='Please enter the ending date in the format of yyyy-mm-dd')

def update(attr, old, new):

d_range = pd.date_range(from_date.value.strip(), to_date.value.strip()).strftime('%Y-%m-%d')

p.plot_width = 25 + len(d_range) * 65 + 25

print(p.plot_width)

p.x_range.factors = d_range.tolist()

p.xaxis[0].ticker = CategoricalTicker(tags=d_range.tolist())

p.xgrid[0].ticker = CategoricalTicker(tags=d_range.tolist())
ds2.data = dict(…)

from_date.on_change(‘value’, update_plot)

to_date.on_change(‘value’, update_plot)

controls = [from_date, to_date]

w_box = widgetbox(controls, width=200, sizing_mode=‘fixed’)

page_layout = row(w_box, p)

page_layout = layout(children=[[w_box, p]])

curdoc().add_root(page_layout)

Many thanks in advance!

Caroline


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9613c0e7-7bf6-4c87-b2fc-5fd95ca22756%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Caroline,

There might a way with CustomJS callbacks, you could try mimicking what the ResizeTool does:

  https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/models/tools/gestures/resize_tool.coffee#L63

However I must warn that that may not currently work well with plots that also have toolbars. We will likely get rid of the ResizeTool for the reason that it does not play very well with the rest of the recent layout improvements.

Certainly one option is to replace the plot with a new plot with the new size, but whether that is sufficient probably depends on the particulars of your situation.

Another option might be to put the plot in a layout container with sizing_mode="stretch_both", and then resize the container. I don't know for certain that this will work yet either. I believe there are still issues to work out around mixed sizing modes, but it bears consideration.

I do regret this change was not caught for the migration notes, I must confess that this is a use case that had never crossed my mind.

Thanks,

Bryan

···

On Jun 29, 2016, at 3:53 PM, Caroline Wang <[email protected]> wrote:

Hi Bryan,

It was possible in 0.11 as I tried before. Is there any workaround I can use to make the plot width updatable?

Thank you!
Caroline

On Wednesday, June 29, 2016 at 1:45:40 PM UTC-7, Bryan Van de ven wrote:
Caroline,

I don't think that the `plot_width` and `plot_height` values are used beyond initialization, so this may not be possible at the moment. It will require some looking into. I'd suggest opening a GH issue with this code to discuss and investigate further.

Thanks,

Bryan

> On Jun 29, 2016, at 3:00 PM, caroli...@gmail.com wrote:
>
> Hi,
>
> I'm trying to make a plot that the plot width and x axis tick labels change with the values from two widget input: to_date and from_date. Now the x axis ticker labels and printed p.plot_width value change as the dates change, but the plot width does not update to the plot.
>
> My code looks like below:
>
> p = Figure(plot_height=600)
> # configure x axis
> p.x_range = FactorRange()
> p.xaxis[0].formatter = DatetimeTickFormatter(formats=dict(
> hours=["%Y-%m-%d"],
> days=["%Y-%m-%d"],
> months=["%Y-%m-%d"],
> years=["%Y-%m-%d"],
> ))
>
> source = ColumnDataSource(data=dict(x=, y=))
> r = p.circle(x='x', y='y', source=source)
>
> from_date = TextInput(value='2016-03-01',
> title='Please enter the starting date in the format of yyyy-mm-dd')
> to_date = TextInput(value='2016-04-30',
> title='Please enter the ending date in the format of yyyy-mm-dd')
>
> def update(attr, old, new):
> d_range = pd.date_range(from_date.value.strip(), to_date.value.strip()).strftime('%Y-%m-%d')
> p.plot_width = 25 + len(d_range) * 65 + 25
> print(p.plot_width)
> p.x_range.factors = d_range.tolist()
> p.xaxis[0].ticker = CategoricalTicker(tags=d_range.tolist())
> p.xgrid[0].ticker = CategoricalTicker(tags=d_range.tolist())
> ds2.data = dict(...)
>
> from_date.on_change('value', update_plot)
> to_date.on_change('value', update_plot)
>
> controls = [from_date, to_date]
> w_box = widgetbox(controls, width=200, sizing_mode='fixed')
> # page_layout = row(w_box, p)
> page_layout = layout(children=[[w_box, p]])
> curdoc().add_root(page_layout)
>
> Many thanks in advance!
> Caroline
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9613c0e7-7bf6-4c87-b2fc-5fd95ca22756%40continuum.io\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7428354e-29a2-4ba1-bee9-d400421eb2d8%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

I should also add, Sarah will have more/better information than me about the possibility of making this work again. She's on away at the moment, but I'll point her at this thread when she is back.

Bryan

···

On Jun 29, 2016, at 4:06 PM, Bryan Van de Ven <[email protected]> wrote:

Caroline,

There might a way with CustomJS callbacks, you could try mimicking what the ResizeTool does:

  https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/models/tools/gestures/resize_tool.coffee#L63

However I must warn that that may not currently work well with plots that also have toolbars. We will likely get rid of the ResizeTool for the reason that it does not play very well with the rest of the recent layout improvements.

Certainly one option is to replace the plot with a new plot with the new size, but whether that is sufficient probably depends on the particulars of your situation.

Another option might be to put the plot in a layout container with sizing_mode="stretch_both", and then resize the container. I don't know for certain that this will work yet either. I believe there are still issues to work out around mixed sizing modes, but it bears consideration.

I do regret this change was not caught for the migration notes, I must confess that this is a use case that had never crossed my mind.

Thanks,

Bryan

On Jun 29, 2016, at 3:53 PM, Caroline Wang <[email protected]> wrote:

Hi Bryan,

It was possible in 0.11 as I tried before. Is there any workaround I can use to make the plot width updatable?

Thank you!
Caroline

On Wednesday, June 29, 2016 at 1:45:40 PM UTC-7, Bryan Van de ven wrote:
Caroline,

I don't think that the `plot_width` and `plot_height` values are used beyond initialization, so this may not be possible at the moment. It will require some looking into. I'd suggest opening a GH issue with this code to discuss and investigate further.

Thanks,

Bryan

On Jun 29, 2016, at 3:00 PM, caroli...@gmail.com wrote:

Hi,

I'm trying to make a plot that the plot width and x axis tick labels change with the values from two widget input: to_date and from_date. Now the x axis ticker labels and printed p.plot_width value change as the dates change, but the plot width does not update to the plot.

My code looks like below:

p = Figure(plot_height=600)
# configure x axis
p.x_range = FactorRange()
p.xaxis[0].formatter = DatetimeTickFormatter(formats=dict(
   hours=["%Y-%m-%d"],
   days=["%Y-%m-%d"],
   months=["%Y-%m-%d"],
   years=["%Y-%m-%d"],
))

source = ColumnDataSource(data=dict(x=, y=))
r = p.circle(x='x', y='y', source=source)

from_date = TextInput(value='2016-03-01',
                     title='Please enter the starting date in the format of yyyy-mm-dd')
to_date = TextInput(value='2016-04-30',
                   title='Please enter the ending date in the format of yyyy-mm-dd')

def update(attr, old, new):
   d_range = pd.date_range(from_date.value.strip(), to_date.value.strip()).strftime('%Y-%m-%d')
p.plot_width = 25 + len(d_range) * 65 + 25
print(p.plot_width)
p.x_range.factors = d_range.tolist()
p.xaxis[0].ticker = CategoricalTicker(tags=d_range.tolist())
p.xgrid[0].ticker = CategoricalTicker(tags=d_range.tolist())
ds2.data = dict(...)

from_date.on_change('value', update_plot)
to_date.on_change('value', update_plot)

controls = [from_date, to_date]
w_box = widgetbox(controls, width=200, sizing_mode='fixed')
# page_layout = row(w_box, p)
page_layout = layout(children=[[w_box, p]])
curdoc().add_root(page_layout)

Many thanks in advance!
Caroline

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
To post to this group, send email to bo...@continuum.io.
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9613c0e7-7bf6-4c87-b2fc-5fd95ca22756%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7428354e-29a2-4ba1-bee9-d400421eb2d8%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Thank you Bryan!

···

On Wednesday, June 29, 2016 at 2:06:53 PM UTC-7, Bryan Van de ven wrote:

Caroline,

There might a way with CustomJS callbacks, you could try mimicking what the ResizeTool does:

    [https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/models/tools/gestures/resize_tool.coffee#L63](https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/models/tools/gestures/resize_tool.coffee#L63)

However I must warn that that may not currently work well with plots that also have toolbars. We will likely get rid of the ResizeTool for the reason that it does not play very well with the rest of the recent layout improvements.

Certainly one option is to replace the plot with a new plot with the new size, but whether that is sufficient probably depends on the particulars of your situation.

Another option might be to put the plot in a layout container with sizing_mode=“stretch_both”, and then resize the container. I don’t know for certain that this will work yet either. I believe there are still issues to work out around mixed sizing modes, but it bears consideration.

I do regret this change was not caught for the migration notes, I must confess that this is a use case that had never crossed my mind.

Thanks,

Bryan

On Jun 29, 2016, at 3:53 PM, Caroline Wang [email protected] wrote:

Hi Bryan,

It was possible in 0.11 as I tried before. Is there any workaround I can use to make the plot width updatable?

Thank you!

Caroline

On Wednesday, June 29, 2016 at 1:45:40 PM UTC-7, Bryan Van de ven wrote:

Caroline,

I don’t think that the plot_width and plot_height values are used beyond initialization, so this may not be possible at the moment. It will require some looking into. I’d suggest opening a GH issue with this code to discuss and investigate further.

Thanks,

Bryan

On Jun 29, 2016, at 3:00 PM, [email protected] wrote:

Hi,

I’m trying to make a plot that the plot width and x axis tick labels change with the values from two widget input: to_date and from_date. Now the x axis ticker labels and printed p.plot_width value change as the dates change, but the plot width does not update to the plot.

My code looks like below:

p = Figure(plot_height=600)

configure x axis

p.x_range = FactorRange()
p.xaxis[0].formatter = DatetimeTickFormatter(formats=dict(
hours=[“%Y-%m-%d”],
days=[“%Y-%m-%d”],
months=[“%Y-%m-%d”],
years=[“%Y-%m-%d”],
))

source = ColumnDataSource(data=dict(x=, y=))
r = p.circle(x=‘x’, y=‘y’, source=source)

from_date = TextInput(value=‘2016-03-01’,
title=‘Please enter the starting date in the format of yyyy-mm-dd’)
to_date = TextInput(value=‘2016-04-30’,
title=‘Please enter the ending date in the format of yyyy-mm-dd’)

def update(attr, old, new):
d_range = pd.date_range(from_date.value.strip(), to_date.value.strip()).strftime(‘%Y-%m-%d’)
p.plot_width = 25 + len(d_range) * 65 + 25
print(p.plot_width)
p.x_range.factors = d_range.tolist()
p.xaxis[0].ticker = CategoricalTicker(tags=d_range.tolist())
p.xgrid[0].ticker = CategoricalTicker(tags=d_range.tolist())
ds2.data = dict(…)

from_date.on_change(‘value’, update_plot)
to_date.on_change(‘value’, update_plot)

controls = [from_date, to_date]
w_box = widgetbox(controls, width=200, sizing_mode=‘fixed’)

page_layout = row(w_box, p)

page_layout = layout(children=[[w_box, p]])
curdoc().add_root(page_layout)

Many thanks in advance!
Caroline


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/9613c0e7-7bf6-4c87-b2fc-5fd95ca22756%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/7428354e-29a2-4ba1-bee9-d400421eb2d8%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Caroline,

          As Bryan said I'm away at

the moment and was only able to take a quick look.

If I use p .width
(not p.plot_width) in
the callback, I’m able to get half way there. The window gets the new correct size but the plot doesn’t redr aw. If I
then manually resize the
browser window th en the
plot grows. Obviously
this isn’t ideal ,
but its almost there.

                                              Definitely

I would raise a bug as
setting p.width should
work to update the
plot width.

                                                  But I'll try

and get back
with a concrete
work around next
week.

Best,

Bird

···

On 6/30/16 4:59 PM, Bryan Van de Ven
wrote:


I should also add, Sarah will have more/better information than me about the possibility of making this work again. She's on away at the moment, but I'll point her at this thread when she is back.
Bryan

On Jun 29, 2016, at 4:06 PM, Bryan Van de Ven wrote:
Caroline, There might a way with CustomJS callbacks, you could try mimicking what the ResizeTool does:
However I must warn that that may not currently work well with plots that also have toolbars. We will likely get rid of the ResizeTool for the reason that it does not play very well with the rest of the recent layout improvements. Certainly one option is to replace the plot with a new plot with the new size, but whether that is sufficient probably depends on the particulars of your situation. Another option might be to put the plot in a layout container with sizing_mode="stretch_both", and then resize the container. I don't know for certain that this will work yet either. I believe there are still issues to work out around mixed sizing modes, but it bears consideration. I do regret this change was not caught for the migration notes, I must confess that this is a use case that had never crossed my mind. Thanks,
Bryan

On Jun 29, 2016, at 3:53 PM, Caroline Wang wrote:
Hi Bryan,
It was possible in 0.11 as I tried before. Is there any workaround I can use to make the plot width updatable?
Thank you!
Caroline
On Wednesday, June 29, 2016 at 1:45:40 PM UTC-7, Bryan Van de ven wrote:
Caroline, I don't think that the `plot_width` and `plot_height` values are used beyond initialization, so this may not be possible at the moment. It will require some looking into. I'd suggest opening a GH issue with this code to discuss and investigate further. Thanks, Bryan

On Jun 29, 2016, at 3:00 PM, wrote: Hi, I'm trying to make a plot that the plot width and x axis tick labels change with the values from two widget input: to_date and from_date. Now the x axis ticker labels and printed p.plot_width value change as the dates change, but the plot width does not update to the plot. My code looks like below: p = Figure(plot_height=600) # configure x axis p.x_range = FactorRange() p.xaxis[0].formatter = DatetimeTickFormatter(formats=dict( hours=["%Y-%m-%d"], days=["%Y-%m-%d"], months=["%Y-%m-%d"], years=["%Y-%m-%d"], )) source = ColumnDataSource(data=dict(x=[], y=[])) r = p.circle(x='x', y='y', source=source) from_date = TextInput(value='2016-03-01', title='Please enter the starting date in the format of yyyy-mm-dd') to_date = TextInput(value='2016-04-30', title='Please enter the ending date in the format of yyyy-mm-dd') def update(attr, old, new): d_range = pd.date_range(from_date.value.strip(), to_date.value.strip()).strftime('%Y-%m-%d') p.plot_width = 25 + len(d_range) * 65 + 25 print(p.plot_width) p.x_range.factors = d_range.tolist() p.xaxis[0].ticker = CategoricalTicker(tags=d_range.tolist()) p.xgrid[0].ticker = CategoricalTicker(tags=d_range.tolist()) ds2.data = dict(...) from_date.on_change('value', update_plot) to_date.on_change('value', update_plot) controls = [from_date, to_date] w_box = widgetbox(controls, width=200, sizing_mode='fixed') # page_layout = row(w_box, p) page_layout = layout(children=[[w_box, p]]) curdoc().add_root(page_layout) Many thanks in advance! Caroline -- You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group. To unsubscribe from this group and stop receiving emails from it, send an email to . To post to this group, send email to . To view this discussion on the web visit . For more options, visit .
-- You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to .
To post to this group, send email to .
To view this discussion on the web visit .
For more options, visit .



Sarah Bird
Developer, Bokeh

    [
      ![Continuum Analytics](http://docs.continuum.io/_static/img/ContinuumWordmark.png)
    ](http://continuum.io)

[email protected]https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/models/tools/gestures/resize_tool.coffee#L63[email protected]caroli…@gmail.combokeh+un…@continuum.iobo@continuum.iohttps://groups.google.com/a/continuum.io/d/msgid/bokeh/9613c0e7-7bf6-4c87-b2fc-5fd95ca22756%40continuum.iohttps://groups.google.com/a/continuum.io/d/optout[email protected]@continuum.iohttps://groups.google.com/a/continuum.io/d/msgid/bokeh/7428354e-29a2-4ba1-bee9-d400421eb2d8%40continuum.iohttps://groups.google.com/a/continuum.io/d/optout

Hi Sarah,

I have same problem with changing dimensions of a plot. Since tabs do not work with responsive I have to have a callback that updates plot dimensions on browser window change. As you said it work half way: when I change window dimension, bokeh figure dimension are updated and next time I change window dimension bokeh figure gets dimension from last step. This is somehow usable but quite annoying. Isn’t it a way to run manual update of plot/figure? Or isn’t there a way to do this directly in browser using some custom_js?
Btw thanks for great work on Bokeh.

Regards,
Petr

···

On Monday, July 4, 2016 at 6:08:12 PM UTC+2, Sarah Bird wrote:

Hi Caroline,

          As Bryan said I'm away at

the moment and was only able to take a quick look.

If I use p .width
(not p.plot_width) in
the callback, I’m able to get half way there. The window gets the new correct size but the plot doesn’t redr aw. If I
then manually resize the
browser window th en the
plot grows. Obviously
this isn’t ideal ,
but its almost there.

                                              Definitely

I would raise a bug as
setting p.width should
work to update the
plot width.

                                                  But I'll try

and get back
with a concrete
work around next
week.

Best,

Bird

  On 6/30/16 4:59 PM, Bryan Van de Ven > wrote:

I should also add, Sarah will have more/better information than me about the possibility of making this work again. She's on away at the moment, but I'll point her at this thread when she is back.
Bryan
On Jun 29, 2016, at 4:06 PM, Bryan Van de Ven <[email protected]> wrote:
Caroline, There might a way with CustomJS callbacks, you could try mimicking what the ResizeTool does:
[https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/models/tools/gestures/resize_tool.coffee#L63](https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/models/tools/gestures/resize_tool.coffee#L63)

However I must warn that that may not currently work well with plots that also have toolbars. We will likely get rid of the ResizeTool for the reason that it does not play very well with the rest of the recent layout improvements. Certainly one option is to replace the plot with a new plot with the new size, but whether that is sufficient probably depends on the particulars of your situation. Another option might be to put the plot in a layout container with sizing_mode="stretch_both", and then resize the container. I don't know for certain that this will work yet either. I believe there are still issues to work out around mixed sizing modes, but it bears consideration. I do regret this change was not caught for the migration notes, I must confess that this is a use case that had never crossed my mind. Thanks,
Bryan
On Jun 29, 2016, at 3:53 PM, Caroline Wang <[email protected]> wrote:
Hi Bryan,
It was possible in 0.11 as I tried before. Is there any workaround I can use to make the plot width updatable?
Thank you!
Caroline
On Wednesday, June 29, 2016 at 1:45:40 PM UTC-7, Bryan Van de ven wrote:
Caroline, I don't think that the `plot_width` and `plot_height` values are used beyond initialization, so this may not be possible at the moment. It will require some looking into. I'd suggest opening a GH issue with this code to discuss and investigate further. Thanks, Bryan
On Jun 29, 2016, at 3:00 PM, [email protected] wrote: Hi, I'm trying to make a plot that the plot width and x axis tick labels change with the values from two widget input: to_date and from_date. Now the x axis ticker labels and printed p.plot_width value change as the dates change, but the plot width does not update to the plot. My code looks like below: p = Figure(plot_height=600) # configure x axis p.x_range = FactorRange() p.xaxis[0].formatter = DatetimeTickFormatter(formats=   dict( hours=["%Y-%m-%d"], days=["%Y-%m-%d"], months=["%Y-%m-%d"], years=["%Y-%m-%d"], )) source = ColumnDataSource(data=dict(x=[
], y=[])) r = p.circle(x='x', y='y', source=source) from_date = TextInput(value='2016-03-01', title='Please enter the starting date in the format of yyyy-mm-dd') to_date = TextInput(value='2016-04-30', title='Please enter the ending date in the format of yyyy-mm-dd') def update(attr, old, new): d_range = pd.date_range(from_date.value.strip(), to_date.value.strip()). strftime('%Y-%m-%d') p.plot_width = 25 + len(d_range) * 65 + 25 print(p.plot_width) p.x_range.factors = d_range.tolist() p.xaxis[0].ticker = CategoricalTicker(tags=d_ range.tolist()) p.xgrid[0].ticker = CategoricalTicker(tags=d_ range.tolist()) ds2.data = dict(...) from_date.on_change('value', update_plot) to_date.on_change('value', update_plot) controls = [from_date, to_date] w_box = widgetbox(controls, width=200, sizing_mode='fixed') # page_layout = row(w_box, p) page_layout = layout(children=[[w_box, p]]) curdoc().add_root(page_layout) Many thanks in advance! Caroline -- You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit [https://groups.google.com/a/continuum.io/d/msgid/bokeh/9613c0e7-7bf6-4c87-b2fc-5fd95ca22756%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/9613c0e7-7bf6-4c87-b2fc-5fd95ca22756%40continuum.io). For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).
-- You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit [https://groups.google.com/a/continuum.io/d/msgid/bokeh/7428354e-29a2-4ba1-bee9-d400421eb2d8%40continuum.io](https://groups.google.com/a/continuum.io/d/msgid/bokeh/7428354e-29a2-4ba1-bee9-d400421eb2d8%40continuum.io).
For more options, visit [https://groups.google.com/a/continuum.io/d/optout](https://groups.google.com/a/continuum.io/d/optout).




Sarah Bird
Developer, Bokeh

    [
      <img alt="Continuum Analytics" src="https://lh6.googleusercontent.com/proxy/VYgVjggTk1hCXSN9wFkffE3I6kxTvJ51tT4KvDXOuKbs1WyFG66k7kt2-vkDimbyxfWtP-d1paJmstMYhPPnDYSUF4rLPoYM2GM2QFM=w5000-h5000" height="30px" width="150px">
    ](http://continuum.io)