I am creating a dashboard at the moment using Plotly express and Panel.
The charts when created with Plotly work fine, but once rendered into the dashboard they become buggy. When hovering over data points no hover information pops up, the plotly tools like zoom, pan and reset disappear and my mouse when moving around the chart turns into a double sided horizontal arrow that you would see when you hover over a scroll bar.
I will put enough code to recreate one of the charts in and outside of the dashboard so anyone who wants to can test and see if they get the same result.
# Getting BTC TWh csv straight from the download link so that whenever the notebook is ran, the data is the latest available
req = requests.get('https://static.dwcdn.net/data/cFnri.csv')
url_content = req.content
csv_file = open('Resources/btc_twh.csv', 'wb')
csv_file.write(url_content)
# Creating BTC TWh dataframe from csv
btc_twh_df = pd.read_csv(Path("Resources/btc_twh.csv"))
# Changing column names for readability and replacing '/' with '-' for plotting reasons
btc_twh_df.columns = ["date", "btc_estimated", "btc_minimum"]
btc_twh_df["date"] = btc_twh_df["date"].str.replace("/", "-")
btc_twh_df_subset.head()
# Plot ETH/BTC TWh with Plotly
btc_twh_chart = px.line(
btc_twh_df,
y="btc_estimated",
title="BTC Energy Usage",
color_discrete_map={"btc_estimated":"orange"},
labels={"btc_estimated":"BTC"})
btc_twh_chart.update_layout(xaxis_title="", yaxis_title="Energy Usage in TWh", template="plotly_dark", height=600, width=1000)
btc_twh_chart.show()
###################
# Plot chart within the dashboard
# TWh panes and column
twh_pane = pn.pane.Plotly(btc_twh_chart)
# Dashboard
dashboard = pn.Tabs(
("Welcome", twh_pane)
)
dashboard.servable()
See how that goes and let me know, it might be my 2017 Macbook Pro, although I haven't had processor issues so far, and my gut tells me it feels more like a bug.
If it works fine and you feel like investigating further here is my repo https://github.com/kez4twez/mining_energy_usage
Feel free to clone it and try and run the whole dashboard.ipynb file and see what happens.
Thanks