import warnings warnings.simplefilter(action="ignore") import dash import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output import dash_bootstrap_components as dbc import pandas as pd import plotly.graph_objs as go import plotly.express as px from jupyterlab_dash import AppViewer viewer = AppViewer() import fbprophet project_id = "cp-gaa-visualization-dev" host = '0.0.0.0' def query_table(sql_query): return pandas_gbq.read_gbq(sql_query, project_id=project_id) def prep_data_for_tsmodel(data): data = data.groupby(['product_title', 'start_date'],
import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Output, Input, State from dash.exceptions import PreventUpdate import datetime import multiprocessing as mp import base64 import pandas as pd import io import json from astropy.io import fits import traceback import dash_table process_manager = mp.Manager() jupyter_viewer = AppViewer() styles = {'pre': {'border': 'thin lightgrey solid', 'overflowX': 'scroll'}} # create global variable only for use inside jupyter app_data = process_manager.dict() debug_data = process_manager.dict() class Viewer(): # app_data = {} def __init__(self, as_website=False): # global app_data # global fig self.as_website = as_website print("first " + str(self.as_website))
def show_jupyter_app(self): jupyter_viewer = AppViewer() self.show_app() jupyter_viewer.show(app)
import dash from dash.dependencies import Input, Output, State import dash_core_components as dcc import dash_html_components as html import dash_table import pandas as pd external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = dash.Dash(__name__, external_stylesheets=external_stylesheets) # Build AppViewer from jupyterlab_dash import AppViewer viewer = AppViewer(port=8000) colors = { "graphBackground": "#F5F5F5", "background": "#ffffff", "text": "#000000" } app.layout = html.Div([ dcc.Upload( id='upload-data', children=html.Div(['Drag and Drop or ', html.A('Select Files')]), style={ 'width': '100%', 'height': '60px',
subtitle="Only occupations with at least 20,000 workers total", color="Minor category", ) # scale_x_continuous(labels = percent_format()) + # scale_y_continuous(labels = percent_format()) ) jobs_gender = pd.read_csv( "https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-03-05/jobs_gender.csv" ) # Build AppViewer from jupyterlab_dash import AppViewer viewer = AppViewer() # + # Build App external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = dash.Dash(__name__, external_stylesheets=external_stylesheets) app.layout = html.Div([ html.Div([ html.Div( [ dcc.Dropdown(id='major-column', options=[{ 'label': i, 'value': i } for i in jobs_gender.major_category.unique()],
@app.callback(Output('hover-data', 'children'), [Input('basic-interactions', 'hoverData')]) def display_hover_data(hoverData): return json.dumps(hoverData, indent=2) @app.callback(Output('click-data', 'children'), [Input('basic-interactions', 'clickData')]) def display_click_data(clickData): return json.dumps(clickData, indent=2) @app.callback(Output('selected-data', 'children'), [Input('basic-interactions', 'selectedData')]) def display_selected_data(selectedData): return json.dumps(selectedData, indent=2) @app.callback(Output('relayout-data', 'children'), [Input('basic-interactions', 'relayoutData')]) def display_relayout_data(relayoutData): return json.dumps(relayoutData, indent=2) jupyter_viewer = AppViewer() jupyter_viewer.show(app) if __name__ == '__main__': app.run_server(debug=True)