import pandas as pd df = pd.read_csv( 'https://gist.githubusercontent.com/chriddyp/c78bf172206ce24f77d6363a2d754b59/raw/c353e8ef842413cae56ae3920b8fd78468aa4cb2/usa-agricultural-exports-2011.csv' ) # df = pd.read_csv('data/workbench_warehouse.csv') # df = pd.read_csv('data/inventory_item.csv') def generate_table(dataframe, max_rows=10): return html.Table( # Header [html.Tr([html.Th(col) for col in dataframe.columns])] + # Body [ html.Tr( [html.Td(dataframe.iloc[i][col]) for col in dataframe.columns]) for i in range(min(len(dataframe), max_rows)) ]) external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = DjangoDash('DataGram', external_stylesheets=external_stylesheets) app.layout = html.Div( children=[html.H4(children='Agriculture Products'), generate_table(df)])
import dash_html_components as html import dash_core_components as dcc from dash.dependencies import Input, Output import requests, base64 from io import BytesIO from django_plotly_dash import DjangoDash external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = DjangoDash('slider', external_stylesheets=external_stylesheets) def enconde_image(image_url): buffered = BytesIO(requests.get(image_url).content) image_base64 = base64.b64encode(buffered.getvalue()) return b'data:image/png;base64,' + image_base64 app.layout = html.Div([ dcc.Dropdown( id='my-dropdown', options=[{ 'label': 'New York City', 'value': 'NYC' }, { 'label': 'Houston', 'value': 'TX' }, { 'label': 'San Francisco', 'value': 'SF' }],
import csv import sys import pathlib import importlib from flask_caching import Cache from home.dash_apps.finished_apps import dash_reusable_components as drc from home.dash_apps.finished_apps import utils as utils # drc = importlib.import_module("dash_reusable_components") # utils = importlib.import_module("utils") external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] APP_PATH = 'C:/Users/Dell-pc/Desktop/Capstone/django/ecfullfill/home/dash_apps/finished_apps' app = DjangoDash('SimpleExample') app.css.append_css({'external_url': 'https://codepen.io/amyoshino/pen/jzXypZ.css'}) # resets the callbacks app.callback_map = {} # sets the title app.title = 'Ecfullfill Capstone' # html content app.layout = html.Div([ #Card Groups html.Div([ #Product Length Button
#import pandas as pd import collections import plotly.graph_objs as go import numpy as np from django.db.models import Count from django_plotly_dash import DjangoDash from django.contrib.staticfiles.templatetags.staticfiles import static from dash.dependencies import Input, Output from cms.models import Booking from users.models import UserMetadata app = DjangoDash('ConfirmedBookings') app.css.append_css({'external_url': static('/css/bWLwgP.css')}) app.layout = html.Div([ html.H4(children='Confirmed Bookings', style={ 'font-family': '"Roboto", "Helvetica", "Arial", "sans-serif"', 'color': '#3C4858', 'margin-top': '15px', 'min-height': 'auto', 'font-weight': '300', 'margin-bottom': '0px', 'text-decoration': 'none', 'font-size': '1.3em', 'line-height': '1.4em', 'margin-bottom': '5px' }),
app = dash.Dash(__name__) app.expanded_callback = app.callback os.chdir("../") print(os.getcwd()) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.local_ventura") print("Django %s" % django.get_version()) if Path(sys.path[0]) == Path(__file__).parent: # Something is adding the __file__ to sys path and causing issues # as forms are being imported things wrong in pycharm sys.path.pop(0) django.setup() else: from django_plotly_dash import DjangoDash app = DjangoDash("Dashboard") # ------------------------------------------------------------------------------- # STYLING ASSETS # ------------------------------------------------------------------------------- COLORS = { "Actives": "#ff9f43", "Inactives": "#a29bfe", "Pledges": "#57606f", "Depledges": "#d63031", "Alumni": "#2e86de", "Fall": "#AC2414", "Winter": "#FCC30C", "Spring": "#E8472D", "Summer": "#000000",
import plotly.graph_objects as go from plotly.subplots import make_subplots from core.models import Customer from core.models import Contract from core.models import Schedule from core.models import Step from django.shortcuts import get_object_or_404 import dash_daq as daq startdate = datetime.datetime.now() # Create figure with secondary y-axis fig = make_subplots(specs=[[{"secondary_y": True}]]) BS = "../../../core/staticfiles/css/bootstrap.css" app = DjangoDash("QuoteApp", external_stylesheets=[BS]) graphcolors = {'background': '#222', 'text': '#fff'} app.layout = html.Div([ html.Div( id="output-one", className='d-sm-flex align-items-center justify-content-between mb-4', children=[ html.Div('Lease quote', className='h3 mb-0'), dbc.Button("Save quote", id="save_quote_button", className="d-none d-md-block btn btn-sm btn-primary"), ]), dbc.CardDeck([ dbc.Card([
import json import dash import dash_core_components as dcc import dash_html_components as html import numpy as np from django_plotly_dash import DjangoDash from numpy import arange from plotly import graph_objs as go from data_models.models import BBR, House, Municipality, categorical_fields from data_models.models import integer_fields as scalar_fields external_stylesheets = ["https://codepen.io/chriddyp/pen/bWLwgP.css"] app = DjangoDash("HistogramVis", external_stylesheets=external_stylesheets) build_years = arange(1800, 2020, 1) styles = { "pre": { "border": "thin lightgrey solid", "overflowX": "scroll", "margin": "auto", "width": "50%", } } municipalities = Municipality.objects.all() app.layout = html.Div(children=[ html.Div( [ html.Div(
def test_dash_stateful_app_client_contract(client): 'Test the state management of a DashApp as well as the contract between the client and the Dash app' from django_plotly_dash.models import StatelessApp # create a DjangoDash, StatelessApp and DashApp ddash = DjangoDash(name="DDash") fill_in_test_app(ddash, write=False) stateless_a = StatelessApp(app_name="DDash") stateless_a.save() stateful_a = DashApp(stateless_app=stateless_a, instance_name="Some name", slug="my-app", save_on_change=True) stateful_a.save() # check app can be found back assert "DDash" in get_local_stateless_list() assert get_local_stateless_by_name("DDash") == ddash assert find_stateless_by_name("DDash") == ddash # check the current_state is empty assert stateful_a.current_state() == {} # set the initial expected state expected_state = { 'inp1': { 'n_clicks': 0, 'n_clicks_timestamp': 1611733453854 }, 'inp2': { 'n_clicks': 5, 'n_clicks_timestamp': 1611733454354 }, 'out1-0': { 'n_clicks': 1, 'n_clicks_timestamp': 1611733453954 }, 'out1-1': { 'n_clicks': 2, 'n_clicks_timestamp': 1611733454054 }, 'out1-2': { 'n_clicks': 3, 'n_clicks_timestamp': 1611733454154 }, 'out1-3': { 'n_clicks': 4, 'n_clicks_timestamp': 1611733454254 }, 'out2-0': { 'n_clicks': 6, 'n_clicks_timestamp': 1611733454454 }, 'out3': { 'n_clicks': 10, 'n_clicks_timestamp': 1611733454854 }, 'out4': { 'n_clicks': 14, 'n_clicks_timestamp': 1611733455254 }, 'out5': { 'n_clicks': 18, 'n_clicks_timestamp': 1611733455654 }, '{"_id":"inp-0","_type":"btn3"}': { 'n_clicks': 7, 'n_clicks_timestamp': 1611733454554 }, '{"_id":"inp-0","_type":"btn4"}': { 'n_clicks': 11, 'n_clicks_timestamp': 1611733454954 }, '{"_id":"inp-0","_type":"btn5"}': { 'n_clicks': 15, 'n_clicks_timestamp': 1611733455354 }, '{"_id":"inp-1","_type":"btn3"}': { 'n_clicks': 8, 'n_clicks_timestamp': 1611733454654 }, '{"_id":"inp-1","_type":"btn4"}': { 'n_clicks': 12, 'n_clicks_timestamp': 1611733455054 }, '{"_id":"inp-1","_type":"btn5"}': { 'n_clicks': 16, 'n_clicks_timestamp': 1611733455454 }, '{"_id":"inp-2","_type":"btn3"}': { 'n_clicks': 9, 'n_clicks_timestamp': 1611733454754 }, '{"_id":"inp-2","_type":"btn4"}': { 'n_clicks': 13, 'n_clicks_timestamp': 1611733455154 }, '{"_id":"inp-2","_type":"btn5"}': { 'n_clicks': 17, 'n_clicks_timestamp': 1611733455554 } } ########## test state management of the app and conversion of components ids # search for state values in dash layout stateful_a.populate_values() assert stateful_a.current_state() == expected_state assert stateful_a.have_current_state_entry("inp1", "n_clicks") assert stateful_a.have_current_state_entry( { "_type": "btn3", "_id": "inp-0" }, "n_clicks_timestamp") assert stateful_a.have_current_state_entry( '{"_id":"inp-0","_type":"btn3"}', "n_clicks_timestamp") assert not stateful_a.have_current_state_entry("checklist", "other-prop") # update a non existent state => no effect on current_state stateful_a.update_current_state("foo", "value", "random") assert stateful_a.current_state() == expected_state # update an existent state => update current_state stateful_a.update_current_state('{"_id":"inp-2","_type":"btn5"}', "n_clicks", 100) expected_state['{"_id":"inp-2","_type":"btn5"}'] = { 'n_clicks': 100, 'n_clicks_timestamp': 1611733455554 } assert stateful_a.current_state() == expected_state assert DashApp.objects.get(instance_name="Some name").current_state() == {} stateful_a.handle_current_state() assert DashApp.objects.get( instance_name="Some name").current_state() == expected_state # check initial layout serve has the correct values injected dash_instance = stateful_a.as_dash_instance() resp = dash_instance.serve_layout() # initialise layout with app state layout, mimetype = dash_instance.augment_initial_layout(resp, {}) assert '"n_clicks": 100' in layout # initialise layout with initial arguments layout, mimetype = dash_instance.augment_initial_layout( resp, {'{"_id":"inp-2","_type":"btn5"}': { "n_clicks": 200 }}) assert '"n_clicks": 100' not in layout assert '"n_clicks": 200' in layout ########### test contract between client and app by replaying interactions recorded in tests_dash_contract.json # get update component route url = reverse('the_django_plotly_dash:update-component', kwargs={'ident': 'my-app'}) # for all interactions in the tests_dash_contract.json for scenario in json.load(dash_contract_data.open("r")): body = scenario["body"] response = client.post(url, json.dumps(body), content_type="application/json") assert response.status_code == 200 response = json.loads(response.content) # compare first item in response with first result result = scenario["result"] if isinstance(result, list): result = result[0] content = response["response"].popitem()[1].popitem()[1] assert content == result # handle state stateful_a.handle_current_state() # check final state has been changed accordingly final_state = { 'inp1': { 'n_clicks': 1, 'n_clicks_timestamp': 1611736145932 }, 'inp2': { 'n_clicks': 6, 'n_clicks_timestamp': 1611736146875 }, 'out1-0': { 'n_clicks': 1, 'n_clicks_timestamp': 1611733453954 }, 'out1-1': { 'n_clicks': 2, 'n_clicks_timestamp': 1611733454054 }, 'out1-2': { 'n_clicks': 3, 'n_clicks_timestamp': 1611733454154 }, 'out1-3': { 'n_clicks': 4, 'n_clicks_timestamp': 1611733454254 }, 'out2-0': { 'n_clicks': 6, 'n_clicks_timestamp': 1611733454454 }, 'out3': { 'n_clicks': 10, 'n_clicks_timestamp': 1611733454854 }, 'out4': { 'n_clicks': 14, 'n_clicks_timestamp': 1611733455254 }, 'out5': { 'n_clicks': 18, 'n_clicks_timestamp': 1611733455654 }, '{"_id":"inp-0","_type":"btn3"}': { 'n_clicks': 8, 'n_clicks_timestamp': 1611736147644 }, '{"_id":"inp-0","_type":"btn4"}': { 'n_clicks': 12, 'n_clicks_timestamp': 1611733454954 }, '{"_id":"inp-0","_type":"btn5"}': { 'n_clicks': 16, 'n_clicks_timestamp': 1611733455354 }, '{"_id":"inp-1","_type":"btn3"}': { 'n_clicks': 9, 'n_clicks_timestamp': 1611736148172 }, '{"_id":"inp-1","_type":"btn4"}': { 'n_clicks': 13, 'n_clicks_timestamp': 1611733455054 }, '{"_id":"inp-1","_type":"btn5"}': { 'n_clicks': 18, 'n_clicks_timestamp': 1611733455454 }, '{"_id":"inp-2","_type":"btn3"}': { 'n_clicks': 10, 'n_clicks_timestamp': 1611736149140 }, '{"_id":"inp-2","_type":"btn4"}': { 'n_clicks': 13, 'n_clicks_timestamp': 1611733455154 }, '{"_id":"inp-2","_type":"btn5"}': { 'n_clicks': 19, 'n_clicks_timestamp': 1611733455554 } } assert DashApp.objects.get( instance_name="Some name").current_state() == final_state
# else: # continent.append('Antarctica') # # index = 0 # # for keys in Countries: # print('\''+ keys + '\'' + ": \'" + continent[index] + '\', ') # index+=1 __name__ = 'Map' external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = DjangoDash(__name__, external_stylesheets=external_stylesheets) colors = { 'background': '#111111', 'text': '#7FDBFF' } countryStats = Profile.objects.values('country').annotate(c=Count('country')).exclude(country='') country_data = {'country': [], 'continent': [], 'count': [], 'iso_alpha': [], } for countryKey in countryStats:
import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output import plotly.graph_objs as go from django_plotly_dash import DjangoDash from umap import UMAP import plotly.express as px external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = DjangoDash('Example', external_stylesheets=external_stylesheets) df = px.data.iris() features = df.loc[:, :'petal_width'] umap_3d = UMAP(n_components=3, init='random', random_state=0) proj_3d = umap_3d.fit_transform(features) fig_3d = px.scatter_3d( proj_3d, x=0, y=1, z=2, color=df.species, labels={'color': 'species'}, ) fig_3d.update_traces(marker_size=5) app.layout = html.Div([ # html.H1('Square Root Slider Graph'), dcc.Graph(id='slider-graph', figure = fig_3d, style={"backgroundColor": "#1a2d46", 'color': '#ffffff'}), # dcc.Slider( # id='slider-updatemode', # marks={i: '{}'.format(i) for i in range(20)}, # max=20, # value=2,
import dash_core_components as dcc import dash_bootstrap_components as dbc import dash_html_components as html from dash.dependencies import Input, Output, State from dash.exceptions import PreventUpdate import plotly.graph_objs as go from django_plotly_dash import DjangoDash from ..models import DeliveryDetail, Delivery, Order, StockControl, Product, ProductCategory from common import utils as common_utils from .. import utils import datetime import copy from common.dashboards import dash_utils, dash_constants app = DjangoDash('StockDio', add_bootstrap_links=True) prefix = 'stock-dio' dropdown_categories_id = prefix + '-dropdown-categories' checklist_select_all_categories_id = prefix + '-checklist-select-all-categories' div_checklist_category_id = prefix + '-div-checklist_category' dropdown_products_id = prefix + '-dropdown-products' checklist_select_all_products_id = prefix + '-checklist-select-all-products' dropdown_y_axis_id = prefix + '-dropdown-y-axis' input_date_range_id = prefix + '-input-date-range' input_avg_sale_date_range_id = prefix + '-input-avg-sale-date-range' dropdown_avg_quantity_period_id = prefix + '-radioitems-quantity-period' radioitems_avg_sale_period_id = prefix + '-radioitems-sale-period' radioitems_chart_type_id = prefix + '-radioitems-chart-type' chart_stock_dio_id = prefix + '-chart-stock-dio' chart_stock_dio_2_id = prefix + '-chart-stock-dio-two'
import time # import dash from django_plotly_dash import DjangoDash import dash_core_components as dcc import dash_html_components as html import numpy as np from dash.dependencies import Input, Output, State from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler from sklearn import datasets import home.dash_apps.utils.dash_reusable_components as drc import home.dash_apps.utils.figures as figs from home.dash_apps.utils.ml_resources import Model, Dataset app = DjangoDash('SVM', ) # server = app.server def generate_data(n_samples, dataset_name, noise): if dataset_name == "moons": return datasets.make_moons(n_samples=n_samples, noise=noise, random_state=0) elif dataset_name == "circles": return datasets.make_circles(n_samples=n_samples, noise=noise, factor=0.5, random_state=1)
#this is only a demo from dash import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output import plotly.graph_objs as go from django_plotly_dash import DjangoDash external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = DjangoDash('SimpleExample', external_stylesheets=external_stylesheets) app.layout = html.Div([ html.H1('Square Root Slider Graph'), dcc.Graph(id='slider-graph', animate=True, style={ "backgroundColor": "#1a2d46", 'color': '#ffffff' }), dcc.Slider( id='slider-updatemode', marks={i: '{}'.format(i) for i in range(20)}, max=20, value=2, step=1, updatemode='drag', ), ])
# Import data path = settings.MEDIA_ROOT data = pd.read_csv(path + '/data/lxf_control_growth.csv') # Define model model = PharmacodynamicModel(path + '/model/tumour_growth_without_treatment.xml') # Define parameter ranges for sliders default_parameters = [0.2, 1, 0.12] min_parameters = [0.01, 0.1, 0.01] max_parameters = [1, 5, 0.5] parameter_names = [ 'Initial tumour volume in cm^3', 'Critical tumour volume in cm^3', 'Growth rate in 1/day' ] # Create figure fig = plot_measurements_and_simulation(data, model, default_parameters, min_parameters, max_parameters, parameter_names) # Set height of image fig.update_layout(height=550) # Create dash app app = DjangoDash('DashBoard') app.layout = html.Div( children=[dcc.Graph(id='simulation-dashboard', figure=fig)])
from django_plotly_dash import DjangoDash from dash.dependencies import Input, Output, State import pandas as pd import plotly.graph_objs as go import dash_bootstrap_components as dbc df = pd.read_csv('12 november to 8 december.csv') df['ds'] = pd.to_datetime(df['ds']) df.set_index('ds', drop=False, inplace=True) df.columns = ['ds', 'yhat', 'yhat_lower', 'yhat_upper', 'y', 'anomaly','location','pred_date', 'indicator'] app = DjangoDash('test', meta_tags=[ {"name": "viewport", "content": "width=device-width, initial-scale=1"} ] ) app.layout = html.Div([dbc.Col( dcc.DatePickerSingle( id='my-date-picker-single', min_date_allowed=dt(2018, 11, 12), max_date_allowed=dt(2018, 12, 8), initial_visible_month=dt(2018, 11, 1), )), dbc.Col( dcc.Input( id='chosen-hour', placeholder='Hour from 0 to 23', type='number',
'Test harness code' from django_plotly_dash import DjangoDash from django.utils.module_loading import import_string from demo.plotly_apps import multiple_callbacks, flexible_expanded_callbacks def stateless_app_loader(app_name): # Load a stateless app return import_string("demo.scaffold." + app_name) demo_app = DjangoDash(name="name_of_demo_app")
# -*- coding: utf-8 -*- import dash import dash_core_components as dcc import dash_html_components as html from django_plotly_dash import DjangoDash import pandas as pd from dash.dependencies import Input, Output from django.conf import settings external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = DjangoDash('DashPlot1', external_stylesheets=external_stylesheets) #app = dash.Dash(__name__) file_name = settings.MEDIA_ROOT + "/thermistorK.txt" data = pd.read_csv(file_name, sep = " ", header=None, names=["time","thermistor", "value"]) #print(data.info()) available_indicators = data['thermistor'].unique() app.layout = html.Div(children=[ #html.H1(children='IFE Dashboard'), #html.Div(children=''' # Created using Dash: A web application framework for Python. #'''), dcc.Graph(id='example-graph'),
import pandas as pd #(version 1.0.0) import plotly #(version 4.5.4) pip install plotly==4.5.4 import plotly.express as px import dash #(version 1.9.1) pip install dash==1.9.1 import dash_table import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Input, Output from django_plotly_dash import DjangoDash from django.conf import settings app = DjangoDash('Datatable') #--------------------------------------------------------------- #Taken from https://www.ecdc.europa.eu/en/geographical-distribution-2019-ncov-cases df = pd.read_excel(settings.MEDIA_ROOT + '/'+"COVID-19.xlsx") dff = df.groupby('countriesAndTerritories', as_index=False)[['deaths','cases']].sum() print (dff[:5]) #--------------------------------------------------------------- app.layout = html.Div([ html.Div([ dash_table.DataTable( id='datatable_id', data=dff.to_dict('records'), columns=[ {"name": i, "id": i, "deletable": False, "selectable": False} for i in dff.columns ], editable=False, filter_action="native", sort_action="native",
config = { 'apiKey': "AIzaSyDmgvnM0dLfnnJr4jpVvHpTWzDlvxHd8nQ", 'authDomain': "datastore-8679e.firebaseapp.com", 'databaseURL': "https://datastore-8679e.firebaseio.com", 'projectId': "datastore-8679e", 'storageBucket': "datastore-8679e.appspot.com", 'messagingSenderId': "827174721908" } #databse connection firebase = pyrebase.initialize_app(config) db = firebase.database() external_css = ( 'https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous' ) appC = DjangoDash('sensorCView') appC.layout = html.Div([ dcc.Graph(id='sensorCGraph', animate=True), dcc.Interval(id='graph-C-update', interval=1 * 4000) ]) @appC.callback(Output('sensorCGraph', 'figure'), events=[Event('graph-C-update', 'interval')]) def senceCUpdaeGraph(): global X global Y X.append(X[-1] + 1) Y.append(db.child('sence3').child('value').get().val()) #print(db.child('sence1').child('value').get().val())
import dash import dash_core_components as dcc import dash_html_components as html import plotly.graph_objs as go #import dpd_components as dpd import numpy as np from django_plotly_dash import DjangoDash from dash.dependencies import Input, Output, State, MATCH, ALL #from .urls import app_name app_name = "DPD demo application" dashboard_name1 = 'dash_example_1' dash_example1 = DjangoDash(name=dashboard_name1, serve_locally=True, app_name=app_name) # Below is a random Dash app. # I encountered no major problems in using Dash this way. I did encounter problems but it was because # I was using e.g. Bootstrap inconsistenyly across the dash layout. Staying consistent worked fine for me. dash_example1.layout = html.Div([ html.Button("Add Filter", id="add-filter", n_clicks=0), html.Div(id='dropdown-container', children=[]), html.Div(id='dropdown-container-output') ]) @dash_example1.expanded_callback(Output('dropdown-container', 'children'), [Input('add-filter', 'n_clicks')], [State('dropdown-container', 'children')])
import dash_bootstrap_components as dbc import pandas as pd import plotly.express as px from dash.dependencies import Input, Output, State from django_plotly_dash import DjangoDash import warnings warnings.filterwarnings("ignore", category=FutureWarning) from dash.dependencies import Input, Output, State from django_plotly_dash import DjangoDash app = DjangoDash('MoneySupply', add_bootstrap_links=True, suppress_callback_exceptions=True, external_stylesheets=[dbc.themes.BOOTSTRAP]) data = 'D:/projects/World_Bank_FCI/data/money_supply/' df_level = pd.read_excel(data + 'money_supply.xlsx', sheet_name='money_supply_level', skiprows=1, nrows=40, usecols='A:F') df_share = pd.read_excel(data + 'money_supply.xlsx', sheet_name='money_supply_share', skiprows=1, nrows=40, usecols='A:W')
from django_plotly_dash import DjangoDash import plotly.graph_objs as go from dash.dependencies import Input, Output, Event, State from apps.utils import parse_my_geoj ''' The performance issue is so huge that maybe I'll skip the animation functions in dash. In dash applications, animation is achieved by update whole figure, however, in plotly, you just switch between frames. The frames function is not supproted in dash. The dash way to achieve simple task in plotly animation is so difficult. I have to hack many stuff. The functions is also buggy. (ex. can't reset n_intervals when I have to reset interval) ''' # b4_css = 'https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css' app = DjangoDash('demo_map') # app = dash.Dash(__name__) mapbox_access_token = 'pk.eyJ1IjoiZXZlbjMxMTM3OSIsImEiOiJjamFydGVtOHk0bHo1MnFyejhneGowaG1sIn0.gyK3haF84TD-oxioghabsQ' name, clats, clons = parse_my_geoj('media/documents/map_final.geojson') max_season = 4 amount = [ np.random.randint(low=10, high=45, size=17).tolist() for i in range(4) ] data = [ go.Scattermapbox( lat=[str(i) for i in clats], lon=[str(i) for i in clons], mode='markers',
# Dash packages import sqlite3 # Data manipulation packages import pandas as pd # Plotly packages import plotly.express as px from django_plotly_dash import DjangoDash from dash_plotly.views.index_view import index_layout con = sqlite3.connect("db.sqlite3") app = DjangoDash('AsxIndexFragment') # replaces dash.Dash index_df = pd.read_sql_query( 'SELECT * FROM stock_asxindexdailyhistory order by index_date', con) fig = px.line(index_df, x='index_date', y='close_index', color='index_name') fig.update_xaxes(rangeselector=dict(buttons=list([ dict(count=1, label="YTD", step="year", stepmode="todate"), dict(count=1, label="1m", step="month", stepmode="backward"), dict(count=6, label="6m", step="month", stepmode="backward"), dict(count=1, label="1y", step="year", stepmode="backward"), dict(count=2, label="2y", step="year", stepmode="backward"), dict(count=5, label="5y", step="year", stepmode="backward"), dict(step="all") ])), ) fig.update_layout( xaxis_rangeslider_visible=False, xaxis_title="Date",
from django_plotly_dash import DjangoDash import os print("el path es:", os.getcwd()) diferencias_top = pd.read_csv( '/home/ubuntu/score-respuesta-inai/deployment_django/deploydjangoinai/diferencias_top_app/dash_apps/finished_apps/diferencias_top.csv' ) diferencias_top = diferencias_top.sort_values('diferencia', ascending=False) respaldo = pd.read_csv( '/home/ubuntu/score-respuesta-inai/deployment_django/deploydjangoinai/diferencias_top_app/dash_apps/finished_apps/diferencias_top.csv' ) df = diferencias_top.copy() external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = DjangoDash('top_interactivo_diferencia', external_stylesheets=external_stylesheets) available_indicators = diferencias_top['dependencia_clean'] app.layout = html.Div([ html.Div( [ html.Div([ dcc.Dropdown(id='dep', options=[{ 'label': i, 'value': i } for i in available_indicators], value='cfe'), dcc.Checklist(id='activaciones', options=[{
from django_plotly_dash import DjangoDash import dash_core_components as dcc import dash_html_components as html import pandas as pd from dash.dependencies import Input, Output external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = DjangoDash('CallBack2', external_stylesheets=external_stylesheets) df = pd.read_csv('https://plotly.github.io/datasets/country_indicators.csv') available_indicators = df['Indicator Name'].unique() app.layout = html.Div([ html.Div([ html.Div([ dcc.Dropdown(id='xaxis-column', options=[{ 'label': i, 'value': i } for i in available_indicators], value='Fertility rate, total (births per woman)'), dcc.RadioItems(id='xaxis-type', options=[{ 'label': i, 'value': i } for i in ['Linear', 'Log']], value='Linear', labelStyle={'display': 'inline-block'}) ],
import dash import dash_core_components as dcc import dash_html_components as html import plotly.graph_objs as go import dpd_components as dpd from dash.exceptions import PreventUpdate from django_plotly_dash import DjangoDash from django_plotly_dash.consumers import send_to_pipe_channel #pylint: disable=too-many-arguments, unused-argument, unused-variable app = DjangoDash('SimpleExample') app.layout = html.Div([ dcc.RadioItems(id='dropdown-color', options=[{ 'label': c, 'value': c.lower() } for c in ['Red', 'Green', 'Blue']], value='red'), html.Div(id='output-color'), dcc.RadioItems(id='dropdown-size', options=[{ 'label': i, 'value': j } for i, j in [('L', 'large'), ('M', 'medium'), ('S', 'small')]],
import dash_html_components as html import dash_core_components as dcc import os from calendar import monthrange from plotly.subplots import make_subplots from django.contrib.staticfiles.storage import staticfiles_storage import requests import pathlib import pandas as pd import numpy as np import os from datetime import datetime, timedelta from PIL import Image from django_plotly_dash import DjangoDash app = DjangoDash('plotly_snodas') def create_plots(): ''' Perform the two data pulls from CDEC. Creates the following dataframes: df: CDEC daily precip data for current water year. df_all_years: Monthly precip data for the last 100 years. OUTPUT: Two html files and two static images. :return: ''' cur_dir = os.getcwd() wy = datetime.today().year # Water Year month_num = datetime.today().month + 2 # Current month number
import numpy as np from keras.datasets import fashion_mnist from tensorflow.keras.utils import to_categorical from keras.models import load_model import io, base64 import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt import shap # from jupyter_dash import JupyterDash # app info # app = JupyterDash(__name__) mnist_fashion_app = DjangoDash("MnistFashionDeepExplainer") styles = {"pre": {"border": "thin lightgrey solid", "overflowX": "scroll"}} # data and basic figure # df = px.data.iris() def find(proj_3d, x, y, z): a = list(proj_3d) print(type(a)) n = [x, y, z] for i in range(len(a)): if x == a[i][0] and y == a[i][1] and z == a[i][2]: return i
'plasma_r', 'plotly3', 'plotly3_r', 'portland', 'portland_r', 'prgn', 'prgn_r', 'pubu', 'pubu_r', 'pubugn', 'pubugn_r', 'puor', 'puor_r', 'purd', 'purd_r', 'purp', 'purp_r', 'purples', 'purples_r', 'purpor', 'purpor_r', 'rainbow', 'rainbow_r', 'rdbu', 'rdbu_r', 'rdgy', 'rdgy_r', 'rdpu', 'rdpu_r', 'rdylbu', 'rdylbu_r', 'rdylgn', 'rdylgn_r', 'redor', 'redor_r', 'reds', 'reds_r', 'solar', 'solar_r', 'spectral', 'spectral_r', 'speed', 'speed_r', 'sunset', 'sunset_r', 'sunsetdark', 'sunsetdark_r', 'teal', 'teal_r', 'tealgrn', 'tealgrn_r', 'tealrose', 'tealrose_r', 'tempo', 'tempo_r', 'temps', 'temps_r', 'thermal', 'thermal_r', 'tropic', 'tropic_r', 'turbid', 'turbid_r', 'twilight', 'twilight_r', 'viridis', 'viridis_r', 'ylgn', 'ylgn_r', 'ylgnbu', 'ylgnbu_r', 'ylorbr', 'ylorbr_r', 'ylorrd', 'ylorrd_r' ]] app = DjangoDash( 'WorldMap', add_bootstrap_links=True ) # dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP]) から変更 # dash_bootstrap_componentsを利用する場合には"add_bootstrap_links=True"を追加する # server = app.serverは削除 app.title = "世界の統計地図" app.layout = dbc.Container([ html.Div([ html.H4("世界の統計地図"), html.Div([html.P("データ元: 世界銀行")], style={"text-align": "right"}), html.Div( [ dcc.Dropdown(id='item-dropdown', options=item_options, value='一人当たりGDP(ドル)') ],
from inventory.models import Location, StockCheck from plotly import offline from stock.models import Product, ProductCategory, Order, Customer, OrderDetail, Supplier from dash.exceptions import PreventUpdate from django.db.models import Avg, Count, Min, Sum, F import cufflinks as cf import numpy as np import statistics from django_pandas.io import read_frame import cufflinks as cf from plotly.subplots import make_subplots import time cf.offline.py_offline.__PLOTLY_OFFLINE_INITIALIZED = True app = DjangoDash('OrderSupplier', add_bootstrap_links=True) _prefix = 'delivery' # ------------------------------------------{Id Graph}-------------------------------------------------------- figure_count_orders_id = dash_utils.generate_html_id(_prefix, 'figure_count_orders_id') figure_count_product_id = dash_utils.generate_html_id( _prefix, 'figure_count_product_id') figure_most_ordred_product_id = dash_utils.generate_html_id( _prefix, 'figure_most_ordred_product_id') figure_most_ordred_supplier_id = dash_utils.generate_html_id( _prefix, 'figure_most_ordred_supplier_id') figure_pie_statuts_product_id = dash_utils.generate_html_id( _prefix, 'figure_pie_statuts_product_id') figure_most_ordred_categories_id = dash_utils.generate_html_id(