holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.42k stars 484 forks source link

Column breaks holoviews aspect + responsive #5054

Open douglas-raillard-arm opened 1 year ago

douglas-raillard-arm commented 1 year ago

ALL software version info

panel: 1.1.0 pandas: 2.0.1 holoviews: 1.16.1 bokeh: 3.1.1 firefox: 113.0.2 (64-bit)

Description of expected behavior and the observed behavior

When a holoviews Curve is using aspect=1 and responsive=True, wrapping that in a Column breaks the sizing.

Complete, minimal, self-contained example code that reproduces the issue

import panel as pn
import holoviews as hv
hv.extension('bokeh')

pn.Column(
    hv.Curve([1,2]).options(aspect=1, responsive=True)
)

Screenshots or screencasts of the bug in action

The aspect ratio is clearly not 1. If the Column layer is removed, the plot scales to the max available width, and the height matches that responsively so that the aspect ratio is respected. Column breaks that: image

philippjfr commented 1 year ago

@mattpap This one is confounding me a bit, it seems like Bokeh completely ignores the aspect_ratio of a figure if it is in a responsive container:

from bokeh.models import Column
from bokeh.plotting import figure

p = figure(sizing_mode='scale_both', aspect_ratio=1)

p.line([1, 2, 3], [1, 2, 3])

Column(children=[Column(children=[p], sizing_mode='scale_both')], height=400, width=800)
mattpap commented 1 year ago

It's a side effect of CSS aspect-ratio being very low priority, which means that a single width/height related CSS property will override it. This can be made to work (ish) if we strip most of bokeh's CSS layout. Again, I need to think about this and experiment we other setups, but I don't have high hopes for this. I think that ultimately aspect ratio will work best in canvas layouts, where we can set priorities ourselves.

philippjfr commented 1 year ago

That seems like a pretty big problem, canvas layouts will very commonly be laid out inside a CSS layout and things shouldn't break depending on how you compose things.