santosjorge / cufflinks

Productivity Tools for Plotly + Pandas
MIT License
3.02k stars 675 forks source link

Will Panel render plots made with cufflinks? #266

Open kez4twez opened 3 years ago

kez4twez commented 3 years ago

I am trying to render charts created by cufflinks in a Panel dashboard but nothing is working, they just won't render.

If I switch the plotting to hvplot it works so I think it's something to do with cufflinks and Panel not being compatible.

# Imports
import panel as pn
pn.extension('plotly')
import plotly.express as px
import requests
import numpy as np
import pandas as pd
import hvplot.pandas
from pathlib import Path
from dotenv import load_dotenv
# Cufflinks
import cufflinks as cf
cf.go_offline()
cf.set_config_file(theme='solar',sharing='public',offline=True) #List of Cufflinks Themes :  ['ggplot', 'pearl', 'solar', 'space', 'white', 'polar', 'henanigans']
eth_btc_twh_chart = eth_btc_twh.iplot(title="BTC/ETH/ETH 2.0 Energy usage in TWh", y=["eth_estimated", "btc_estimated", "eth_2.0"], yTitle="Terrawatt Hours")
eth_btc_twh_usd_chart = eth_btc_twh.iplot(title="BTC/ETH/ETH 2.0 Energy Cost", y=["btc_estimated", "eth_estimated", "eth_2.0"], yTitle="USD")
# Create the title
title = "Crypto Mining Energy Usage"

# Define the welcome text
welcome = "This dashboard presents a visual analysis of the ongoing energy usage of Bitcoin and Ethereum mining compared to eachother, Ethereum 2.0 and Traditional finance. The aim is to inform the user and convey that the Proof of Stake method is much more beneficial to the environment than the traditional Proof of Work method that Bitcoin and Ethereum in its current state use."

# TWh panes and column
twh_column = pn.Column(welcome, eth_btc_twh_chart, eth_btc_twh_usd_chart)

# Dashboard
dashboard = pn.Tabs(
    ("Welcome", twh_column)
)

twh_column

Screen Shot 2021-07-09 at 3 47 18 pm

The most pertinent sections of my code are these^

I know you won't be able to recreate because you need the dataframes, but does all of this look right to you?

If anyone knows whether cufflinks is compatible with Panel or not please let me know. If not does anyone have any other suggestions for making a dashboard that is compatible with cufflinks?

My aim is to deploy through Heroku or something similar.