Beispiel #1
0
    def run(self):
        self.app = dash.Dash()
        # temp
        self.app.css.append_css({
            "external_url": "https://codepen.io/chriddyp/pen/bWLwgP.css"
        })
        self.app.layout = html.Div([
            # Page Header
            html.Div([
                html.H1('CryptoBot')
            ]),

            # Dropdown Grid
            html.Div([
                html.Div([
                    # Select Symbol Dropdown
                    html.Div([
                        html.Div('Select Symbol', className='three columns'),
                        html.Div(dcc.Dropdown(id='division-selector'),
                                 className='nine columns')
                    ]),
                ], className='six columns'),

                # Empty
                html.Div(className='six columns'),
            ], className='twleve columns'),

        ])

        self.app.use_reloader = False
        self.app.run_server(host="127.0.0.1", port=8050, debug=False)
Beispiel #2
0
    def __init__(self, name):
        self.app = dash.Dash(__name__)
        self.app.css.config.serve_locally = True
        self.app.scripts.serve_locally = True
        self.server = self.app.server
        self.curr_idx = 0
        self.curr_cash = 0
        self.curr_assets = 0
        self.curr_loss = 0
        self.curr_profit = 0
        self.trades = self.load_trade_report()
        self.curr_window = []
        self.disable = 9999999

        self.serve_layout()
Beispiel #3
0
def register_dashapps(app):
    from app.dashapp.layout import serve_layout
    from app.dashapp.callbacks import register_callbacks

    # Meta tags for viewport responsiveness
    meta_viewport = {"name": "viewport", "content": "width=device-width, initial-scale=1, shrink-to-fit=no"}

    dashapp = dash.Dash(__name__,
                        server=app,
                        url_base_pathname='/dashboard/',
                        assets_url_path=os.path.join(app.root_path, 'dashapp', 'assets'),
                        assets_folder=os.path.join(app.root_path, 'dashapp', 'assets'),
                        meta_tags=[meta_viewport])

    with app.app_context():
        dashapp.title = 'Ignite E-Health'
        dashapp.layout = serve_layout
        register_callbacks(dashapp)
Beispiel #4
0
import orjson
from dash import dash
import dash_bootstrap_components as dbc

import sys
import os
d = os.popen("cd ../../core/src && pwd").read()[:-1]
sys.path.append(d)

external_stylesheets = [
    dbc.themes.BOOTSTRAP,
    "https://codepen.io/chriddyp/pen/bWLwgP.css",
    "../spc-custom-styles.css",
]

app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
data = orjson.loads(open("/usr/local/share/spark-luxmeter/config.json", "r").read())
Beispiel #5
0
from datetime import datetime

from dash import dash

import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, Event, State
from dash.exceptions import CantHaveMultipleOutputs

app = dash.Dash(__name__)
app.config.supress_callback_exceptions = True

IDS = [1, 2, 3]


def divs_list():
    return [
        html.Div([
            dcc.Markdown('', id='model-{}-markdown'.format(id)),
            html.P('', id='model-{}-p'.format(id)),
            html.Button('Delete',
                        id='model-{}-delete-button'.format(id),
                        style={'width': '49%'}),
            html.Button('Start/Stop',
                        id='model-{}-toggle-button'.format(id),
                        style={
                            'marginLeft': '2%',
                            'width': '49%'
                        }),
            html.Hr()
        ],
Beispiel #6
0
from dash import dash

from config import AppConfig
from views import BaseView

WebApp = dash.Dash(
    __name__,
    external_stylesheets=AppConfig.EXTERNAL_STYLESHEETS,
    external_scripts=AppConfig.EXTERNAL_SCRIPTS,
    suppress_callback_exceptions=True,
    update_title=None,
    title=AppConfig.APP_TITLE,
)

WebApp.layout = BaseView.layout
server = WebApp.server

from controllers import *

if __name__ == "__main__":
    WebApp.run_server(debug=False)
def init_dashboard(server):
    """Create a Plotly Dash dashboard."""
    dash_app = dash.Dash(
        server=server,
        routes_pathname_prefix='/dashapp/',
        external_stylesheets=[dbc.themes.SUPERHERO]
    )

    # Data Connection
    engine = db.create_engine('sqlite:///.//flaskapp//data//master.db')
    connection = engine.connect()

    # Get values for controls
    state = get_unique(connection, "data", "STATE")
    year = get_unique(connection, "data", "YEAR")
    week_flag = get_unique(connection, "data", "Weekened_Flag")
    holiday_flag = get_unique(connection, "data", "Holiday_Flag")
    connection.close()

    # Build Components
    controls = [
        dcc_multiselect(id="states", label="State", values=state),
        dcc_multiselect(id="years", label="Year", values=year),
        option_menu(id="week_flag", label="Weekend_Flag", values=week_flag),
        option_menu(id="holiday_flag", label="Holiday_Flag", values=holiday_flag),
        dbc.Button("Refresh", color="primary", id="button_refresh"),
    ]
    app_graph1 = dcc.Graph(id="app_graph1", style={"width": "800px", "height": "400px"})
    app_graph2 = dcc.Graph(id="app_graph2", style={"width": "800px", "height": "400px"})
    card1 = dbc.Card(controls, body=True)
    card2 = dbc.Card([dcc.Markdown(id="sql-query")], body=True)

    # Create Layout
    dash_app.layout = dbc.Container(
        fluid=True,
        children=[
            html.H1("A dash embedded application for electricity forecast in FLASK",
                    style={'color': '#ff6600',
                           'fontSize': 20, 'textAlign': 'center'}),
            html.Hr(),
            dbc.Row(
                [
                 dbc.Col([card1, card2], md=3),
                 dbc.Col([app_graph1, app_graph2], md=4),
                ]
             ),
            ],
        style={"margin": "auto"},
    )

    @dash_app.callback(
        [
            Output("app_graph1", "figure"),
            Output("app_graph2", "figure"),
            Output("sql-query", "children"),
        ],
        [Input("button_refresh", "n_clicks")],
        [
            State("states", "value"),
            State("years", "value"),
            State("week_flag", "value"),
            State("holiday_flag", "value"),
        ],
    )
    def update(n_clicks, states, years, week_flag, holiday_flag):
        if len(states) == 1:
            states = "('" + states[0] + "')"
        else:
            states = tuple(states)

        if len(years) == 1:
            years = "('" + str(years[0]) + "')"
        else:
            years = tuple(years)
        query = dedent(
            f"""
            SELECT CAST(DEMAND AS DECIMAL(10,2)) AS DEMAND, MAX_TEMP, MIN_TEMP, STATE, YEAR, Holiday_Flag, Weekened_Flag 
            FROM data 
            WHERE
            STATE IN {states} AND
            YEAR IN {years} AND
            Weekened_Flag = '{week_flag}' AND
            Holiday_Flag = '{holiday_flag}';
            """
        )
        df = connect_read_sql(query=query, engine=engine)
        connection.close()

        #data manipulation

        df1 = pd.DataFrame({'DEMAND': df.groupby(['STATE', 'YEAR'])['DEMAND'].sum()}).reset_index()

        #figures
        app_graph1 = px.line(df1, x="YEAR", y="DEMAND", color="STATE", title='Electricity Consumption in Australia')
        app_graph1.update_xaxes(type='category')
        app_graph2 = px.scatter(df, x="MAX_TEMP", y="DEMAND", color="STATE",
                                title='Scatter Plot Demand Vs Maxmimum Temperature')

        return app_graph1, app_graph2, f"```\n{query}\n```"

    return dash_app.server
Beispiel #8
0
from piwi_gym.configs import *
import os
import json
from glob import glob


def load_trade_report():
    f_name = json_report_path.format('*')
    full_pth = glob(f_name)[0]
    with open(full_pth, 'r', os.O_NONBLOCK) as reader:
        data = json.load(reader)

    return data


app = dash.Dash()
server = app.server
app.css.config.serve_locally = True
app.scripts.serve_locally = True
server = app.server

trades = load_trade_report()


class Viewer(object):
    def __init__(self, name):
        self.app = dash.Dash(__name__)
        self.app.css.config.serve_locally = True
        self.app.scripts.serve_locally = True
        self.server = self.app.server
        self.curr_idx = 0
Beispiel #9
0
        return None

    configuration = openapi_client.Configuration(
        host="https://hugo-staging.pragmaticindustries.com/api")
    client = ApiClient(configuration=configuration,
                       header_name="Authorization",
                       header_value=f"Bearer {access_token}")

    return client


# Build a regular Dash app, only pass the server...
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = dash.Dash(__name__,
                external_stylesheets=external_stylesheets,
                server=server)

# assume you have a "long-form" data frame
# see https://plotly.com/python/px-arguments/ for more options
df = pd.DataFrame({
    "Fruit": ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"],
    "Amount": [4, 1, 2, 2, 4, 5],
    "City": ["SF", "SF", "SF", "Montreal", "Montreal", "Montreal"]
})

fig = px.bar(df, x="Fruit", y="Amount", color="City", barmode="group")

app.layout = html.Div(children=[
    html.H1(children='Hello Dash', id="headline"),
    dcc.Interval(id='interval-component', interval=1000 * 1000, n_intervals=0),
               [0.7777777777777778, 'rgb(136,65,157)'],
               [0.8888888888888888, 'rgb(129,15,124)'],
               [0.9999999999999999, 'rgb(69,117,180)'], [1.0, 'rgb(77,0,75)']]

colors = {'background': '#111111', 'text': '#7FDBFF'}

all_options = {
    'Time Range': ['month', 'hour', 'Day_of_Week', 'week_in_month'],
    'Data Attributes': [
        'Accident_Severity', 'Number_of_Vehicles', 'Number_of_Casualties',
        'Road_Type', 'Speed_limit', 'Light_Conditions', 'Weather_Conditions',
        'Road_Surface_Conditions', 'Urban_or_Rural_Area'
    ]
}

app = dash.Dash(__name__, external_stylesheets=[dbc.themes.MATERIA])

app.layout = html.Div([
    dbc.Card(
        dbc.CardBody([
            html.
            H3(children='Visualization and Analysis of Traffic Incidents in UK',
               style={
                   'textAlign': 'center',
                   'color': 'red'
               }),
            html.Br(),
            dcc.Tabs([
                dcc.Tab(
                    label='Exploratory Data Analysis',
                    children=[
Beispiel #11
0
import subprocess
from uuid import uuid4
from pathlib import Path

import pandas as pd
import networkx as nx
import plotly.graph_objects as go
from dash import dash, html, dcc, Input, Output, callback_context

from das.common import XML_REPORTS, Logger

logger = Logger()

######################### PASS THE CSS INTO DASH ########################
app = dash.Dash(
    __name__,
    external_stylesheets=['https://codepen.io/chriddyp/pen/bWLwgP.css'])

################### CONVERT XML TO CSV ###################
filename = f'/tmp/{uuid4()}.csv'
for xml in XML_REPORTS:
    if subprocess.call([
            sys.executable,
        (Path(__file__) / '../Nmap-XML-to-CSV/nmap_xml_parser.py').resolve(),
            '-f', xml, '-csv', filename
    ],
                       stdout=subprocess.DEVNULL,
                       stderr=subprocess.STDOUT) == 0:
        logger.print_success(f'Updated {filename} with {xml} data')
    else:
        logger.print_error(f'Failed processing {xml}')
Beispiel #12
0
from dash import dash
from flask import Flask

server = Flask(__name__)
app = dash.Dash(__name__, server=server)


@server.route("/")
def hello():
    return "Hello World!"
Beispiel #13
0
    def setupOn(self, server, data_manager, project_name):
        settings_app = dash.Dash(__name__,
                                 server=server,
                                 url_base_pathname=self.url,
                                 external_stylesheets=stylesheet)
        settings_app.layout = html.Div(
            style={'padding-top': '10%'},
            children=[
                html.Div(
                    className='six columns offset-by-three',
                    style={
                        'background-color': '#edf5ff',
                        'padding-top': '3%',
                        'padding-bottom': '5%',
                        'padding-left': '5%',
                        'padding-right': '5%',
                    },
                    children=[
                        html.Div(
                            className='row',
                            children=[
                                html.Div([
                                    html.H3(
                                        style={'padding': '0%'},
                                        children=
                                        'Do you want to shutdown the visualization tool?',
                                    ),
                                ])
                            ],
                        ),
                        html.Div(
                            className='row',
                            children=[
                                dcc.Input(
                                    id="project-password",
                                    type='password',
                                    placeholder="Enter project password...",
                                ),
                                html.Button(children='Shutdown',
                                            id='shutdown',
                                            n_clicks=0,
                                            style={
                                                'background-color': 'red',
                                                'color': 'white'
                                            }),
                            ],
                        )
                    ],
                ),
            ])

        @settings_app.callback([
            Output('project-password', 'value'),
            Output('project-password', 'placeholder')
        ], [Input('shutdown', 'n_clicks')],
                               [State('project-password', 'value')])
        def stop_software(n_clicks, password):
            value = "",
            placeholder = "Enter password..."
            if n_clicks > 0:
                if ProjectManager().verify_password(project_name, password):
                    shutdown_software()
                    placeholder = "Shutting down..."
                else:
                    placeholder = "Incorrect password..."
            return [value, placeholder]
Beispiel #14
0
from dash import dash
import dash_bootstrap_components as dbc

app = dash.Dash(
    __name__,
    external_stylesheets=[dbc.themes.SUPERHERO],
    meta_tags=[{
        'name': 'viewport',
        'content': 'width=device-width'
    }],
)

app.title = 'Different Eras of Music'
app.config.suppress_callback_exceptions = True
Beispiel #15
0
import logging
import os

from dash import dash
from flask_login import LoginManager, UserMixin

from apps.db.dao.user_dao import AppUser

mapbox_access_token = 'pk.eyJ1IjoiYWhzLXZhIiwiYSI6ImNraGsyMWVmdDByOWszNnNkdzJqcHpwOWMifQ.llITOAaVvDUflVgenIPPlw'

app = dash.Dash(__name__,
                suppress_callback_exceptions=True,
                meta_tags=[{
                    'name': 'viewport',
                    'content': 'width=device-width, initial-scale=1.0'
                }])
app.title = 'Locatory'
server = app.server
server.config.update(SECRET_KEY=os.urandom(12))
server.logger.setLevel(logging.INFO)

# LoginManager
login_manager = LoginManager()
login_manager.init_app(server)
login_manager.login_view = '/login'


# Creating User class with UserMixin
class User(UserMixin):
    def __init__(self, user_json):
        self.user_json = user_json