Commit ·
7f27964
1
Parent(s): f948ef3
Create index.py
Browse files
index.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""The purpose of this app is to test that a **multi-page Dashboard Layout** similar to the
|
| 2 |
+
[bootstrap dashboard template](https://getbootstrap.com/docs/4.3/examples/dashboard/)
|
| 3 |
+
from [getboostrap.com](https://getbootstrap.com/) can be implemented in
|
| 4 |
+
[Panel](https://panel.pyviz.org/).
|
| 5 |
+
"""
|
| 6 |
+
import hvplot.pandas # pylint: disable=unused-import
|
| 7 |
+
import pandas as pd
|
| 8 |
+
import panel as pn
|
| 9 |
+
|
| 10 |
+
BOOTSTRAP_DASHBOARD_CHART_URL="https://awesomepanel.blob.core.windows.net/resources/bootstrap_dashboard/bootstrap_dashboard_chart.csv"
|
| 11 |
+
BOOTSTRAP_DASHBOARD_TABLE_URL="https://awesomepanel.blob.core.windows.net/resources/bootstrap_dashboard/bootstrap_dashboard_table.csv"
|
| 12 |
+
|
| 13 |
+
COLOR="#0072B5"
|
| 14 |
+
|
| 15 |
+
@pn.cache
|
| 16 |
+
def _get_chart_data():
|
| 17 |
+
return pd.read_csv(BOOTSTRAP_DASHBOARD_CHART_URL)
|
| 18 |
+
|
| 19 |
+
@pn.cache
|
| 20 |
+
def _get_table_data():
|
| 21 |
+
return pd.read_csv(BOOTSTRAP_DASHBOARD_TABLE_URL)
|
| 22 |
+
|
| 23 |
+
def _holoviews_chart():
|
| 24 |
+
"""## Dashboard Orders Chart generated by HoloViews"""
|
| 25 |
+
data = _get_chart_data()
|
| 26 |
+
line_plot = data.hvplot.line(
|
| 27 |
+
x="Day",
|
| 28 |
+
y="Orders",
|
| 29 |
+
height=500,
|
| 30 |
+
line_color=COLOR,
|
| 31 |
+
line_width=6,
|
| 32 |
+
)
|
| 33 |
+
scatter_plot = data.hvplot.scatter(x="Day", y="Orders", height=300,).opts(
|
| 34 |
+
marker="o",
|
| 35 |
+
size=10,
|
| 36 |
+
color=COLOR,
|
| 37 |
+
)
|
| 38 |
+
fig = line_plot * scatter_plot
|
| 39 |
+
gridstyle = {
|
| 40 |
+
"grid_line_color": "black",
|
| 41 |
+
"grid_line_width": 0.1,
|
| 42 |
+
}
|
| 43 |
+
fig = fig.opts(
|
| 44 |
+
responsive=True,
|
| 45 |
+
toolbar=None,
|
| 46 |
+
yticks=list(
|
| 47 |
+
range(
|
| 48 |
+
12000,
|
| 49 |
+
26000,
|
| 50 |
+
2000,
|
| 51 |
+
)
|
| 52 |
+
),
|
| 53 |
+
ylim=(
|
| 54 |
+
12000,
|
| 55 |
+
26000,
|
| 56 |
+
),
|
| 57 |
+
gridstyle=gridstyle,
|
| 58 |
+
show_grid=True,
|
| 59 |
+
)
|
| 60 |
+
return fig
|
| 61 |
+
|
| 62 |
+
app = pn.extension("tabulator", sizing_mode="stretch_width")
|
| 63 |
+
|
| 64 |
+
pn.template.FastListTemplate(
|
| 65 |
+
site="Awesome Panel", site_url="https://awesome-panel.org", title="Bootstrap Dashboard",
|
| 66 |
+
main=[
|
| 67 |
+
pn.Column(
|
| 68 |
+
pn.pane.Markdown("## Dashboard"),
|
| 69 |
+
_holoviews_chart()),
|
| 70 |
+
pn.Column(pn.pane.Markdown("## Section Title"),
|
| 71 |
+
pn.widgets.Tabulator(_get_table_data(), layout='fit_data_stretch')),
|
| 72 |
+
], main_max_width="800px", main_layout=None,
|
| 73 |
+
).servable()
|