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

Unexpected initial layout with DataTable and layout() #5131

Closed
ababino opened this issue Sep 9, 2016 · 4 comments
Closed

Unexpected initial layout with DataTable and layout() #5131

ababino opened this issue Sep 9, 2016 · 4 comments

Comments

@ababino
Copy link

@ababino ababino commented Sep 9, 2016

Dear all,

thanks for this marvelous library! I have written a small dashboard to follow some processes. The dashboard consists of three tables that I render with the layout() function. The problem is that the initial layout has the wrong width making the tables overlap each other.

initial_layout
After moving the browser's window (with the mouse I mean) the elements re-accommodate and they layout as I expected.

final_layout
In order to reproduce the behavior I saved the code below and I run bokeh serve test.py

test.py file:

from bokeh.layouts import widgetbox, layout
from bokeh.models import ColumnDataSource
from bokeh.models.widgets import DataTable, TableColumn, NumberFormatter
from bokeh.plotting import curdoc
import pandas as pd

df = pd.DataFrame({'Host': ['foo', 'foo', 'bar', 'bar', 'foo', 'foo', 'bar', 'bar'],
                   'JobRuntime': [215, 351, 756, 654, 684, 654, 654, 658],
                   'Exitval': [0, 0, 0, 255, 0, 255, 0, 0]})
source = ColumnDataSource(df)
columns = [
        TableColumn(field="Host", title="Host"),
        TableColumn(field="JobRuntime", title="JobRuntime",
                    formatter=NumberFormatter(format='00:00:00')),
        TableColumn(field="Exitval", title="Exitval"),
    ]
data_table = DataTable(source=source, columns=columns, fit_columns=True,
                       width=400, height=400)

counts = df.pivot_table(columns='Host', index='Exitval', values='JobRuntime',
                        aggfunc=len, margins=True)
counts = counts.reset_index()
counts.columns = counts.columns.map(str)
columns2 = [TableColumn(field=val, title=val) for val in counts.columns]
counts = ColumnDataSource(counts)
data_table2 = DataTable(source=counts, columns=columns2, fit_columns=True,
                        width=800, height=200)

means = df.pivot_table(columns='Host', index='Exitval', values='JobRuntime',
                       margins=True)
means = means.reset_index()
means.columns = means.columns.map(str)
columns3 = [TableColumn(field='Exitval', title='ExitVal')]
columns3 += [TableColumn(field=val, title=val, formatter=NumberFormatter(format='00:00:00')) for val in means.columns[1:]]
means = ColumnDataSource(means)
data_table3 = DataTable(source=means, columns=columns3, fit_columns=True,
                        width=800, height=200)

curdoc().add_root(layout([[widgetbox(data_table), widgetbox(data_table2, data_table3)]], width=3000, sizing_mode='stretch_both'))

The output of bokeh info is
Python version : 2.7.11 |Anaconda 4.0.0 (64-bit)| (default, Dec 6 2015, 18:08:32)
IPython version : 4.1.2
Bokeh version : 0.12.2
BokehJS static path : /home/andres/anaconda2/lib/python2.7/site-packages/bokeh/server/static

Thanks again

@birdsarah
Copy link
Member

@birdsarah birdsarah commented Sep 9, 2016

Thanks for the report and your patience @ababino.

@gryBox
Copy link
Contributor

@gryBox gryBox commented Sep 10, 2016

We also have seen intermittent unexpected behavior when moving the browser window across screens. In our case the bokeh doc loads fine, but when moving the browser across screens, the graph disappears. Reloading the document was our fix :)

Using Windows 7 (64-bit)
python 3.5.x
bokeh 12.1 +

@bryevdv
Copy link
Member

@bryevdv bryevdv commented Jun 1, 2017

With 0.12.6dev7 I now get this from the start:

screen shot 2017-05-31 at 19 40 09

Perhaps this can be closed?

@bryevdv
Copy link
Member

@bryevdv bryevdv commented Jun 1, 2017

@ababino @gryBox if you have the chance to install and test with 0.12.6dev7 to confirm whether this is resolved it would be appreciated.

cc @mattpap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

5 participants
You can’t perform that action at this time.