def create_pie(value, name, color='rgba(59, 64, 72, 100)', **card_props):
    # TODO: Read in bgcolor from theme
    fig = {
        'data': [{
            'values': value,
            'textinfo': 'none',
            'hoverinfo': 'value+percent',
            'type': 'pie',
            'hole': 0.5,
            'marker': {
                'colors': [color, 'var(--border)'],
                'line': {
                    'width': 20,
                    'color': 'var(--background)'
                }
            }
        }],
        'layout': {
            'margin': {
                'l': 10,
                'r': 10,
                't': 10,
                'b': 10
            },
            'showlegend': False,
            'height': 200,
        }
    }

    pie = ddk.Graph(id='id' + name,
                    figure=fig,
                    config={'displayModeBar': False})

    return ddk.Card(pie, **card_props)
Beispiel #2
0
from dash.dependencies import Input, Output

app = dash.Dash(__name__)
server = app.server  # expose server variable for Procfile

app.layout = ddk.App([
    ddk.Header([
        ddk.Logo(src=app.get_asset_url('logo.png')),
        ddk.Title('Dash Enterprise Sample Application'),
    ]),
    ddk.Row(children=[
        ddk.Card(children=ddk.Graph(figure={
            'data': [{
                'x': [1, 2, 3, 4],
                'y': [4, 1, 6, 9],
                'line': {
                    'shape': 'spline'
                }
            }]
        }, )),
    ]),
    ddk.Row(children=[
        ddk.Card(width=50,
                 children=ddk.Graph(figure={
                     'data': [{
                         'x': [1, 2, 3, 4],
                         'y': [4, 1, 6, 9],
                         'line': {
                             'shape': 'spline'
                         }
                     }]
         'max-height': 100,
         'width': 'auto'
     }),
     ddk.Title('TELONAS2'),
     ddk.SectionTitle('', id='final_date'),
     html.Button('Refresh', style={'float': 'right'}, id='refresh', n_clicks=0),
 ]),
 ddk.Block(
     children=[
         dcc.Tabs(id='selected-tab', value='load',
                  children=[
                      dcc.Tab(label="Load", value='load',
                              children=[ddk.Card(width=100,
                                                 children=[
                                                     dcc.Loading(id='load_loader', children=[
                                                         ddk.Graph(id="load_plot", config=graph_config)]),
                                                         ]
                                                     )
                                                 ]
                                                 )
                                        ]
                              ),
                      dcc.Tab(label="Profiles", value='profiles',
                              children=[ddk.Card(width=100,
                                                 children=[
                                                     dcc.Loading(id='profile_loader', children=[
                                                         ddk.Graph(id="profile_plot", config=graph_config)])
                                                 ]
                                                 )
                                        ]
                              )
Beispiel #4
0
                             ),
                         ]
                     ),  # end of app-description Card and it's children
                 ]),  # end of About tab and it's children
         ]),  # end of dcc.Tabs() and it's children
     ]  # end of left-hand column - children
 ),  # end of left-hand column
 ddk.Block(  # right-hand column
     width=80,
     children=[
         ddk.Card(  # map of canada
             padding=0,
             children=[
                 ddk.CardHeader(
                     title='Geographic Representation of Funding'),
                 ddk.Graph(id='map-graph'),
             ]),
         ddk.Card(  # Companies Dataframe Table
             children=[
                 ddk.CardHeader(
                     title='Search by Company or Project Keyword'),
                 ddk.DataTable(
                     id='companies-table',
                     columns=[{
                         "name": i,
                         "id": i
                     } for i in df[[
                         'Company_Name', 'Project', '$_Amount'
                     ]].columns],
                     fill_width=False,
                     filter_action='native',
Beispiel #5
0
import dash_core_components as dcc
from dash.dependencies import Input, Output
import plotly.graph_objs as go
import requests
from datetime import datetime as dt
r = requests.get("https://financialmodelingprep.com/api/v3/quote/BTCUSD")

time = []
price = []

app = dash.Dash()

server = app.server

app.layout = ddk.App(children=[
    ddk.Card(ddk.Graph(id="graph")),
    dcc.Interval(id="liveupdate", interval=10000, n_intervals=0),
])


@app.callback(Output("graph", "figure"), [Input("liveupdate", "n_intervals")])
def gaph_update(n):

    price.append(
        requests.get("https://financialmodelingprep.com/api/v3/quote/BTCUSD").
        json()[0]["price"])
    time.append(
        dt.utcfromtimestamp(
            int(
                requests.get(
                    "https://financialmodelingprep.com/api/v3/quote/BTCUSD").
Beispiel #6
0
                        # children=[
                        #         dcc.Graph(figure=px.scatter_geo(df2, lat='Latitude', lon='Longitude', color="Period", size='LatLongPeriodCount',
                        #         hover_name="Country").update_geos(projection_type="orthographic")),
                        # ],
                        # ),
                        ddk.Card(
                        width=43,
                        children=[
                                ddk.CardHeader(title='Which Country Fossils Were Found'),
                                dcc.Graph(id='display-map', figure={}),
                        ],),
                        ddk.Card(
                        width=56,
                        children=[
                                ddk.CardHeader(title='Total Found by Country'),
                                ddk.Graph(id='display-scatter', figure={}),
                        ],
                        ),
                        # px.scatter(df, x="MillionsYears", y=len(df.axes[0]), color="Period"),
                ],
                ),
                
                ]
        ),


@app.callback(
    Output('display-type', 'options'),
    [Input('period', 'value')],
)
def set_type_options(chosen_type):
Beispiel #7
0
    ddk.Block(children=[
        ddk.DataCard(id="dc1", width=25, label="Dividend Yield", value="-"),
        ddk.DataCard(id="dc2", width=25, label="Peg Ratio", value="-"),
        ddk.DataCard(id="dc3", width=25, label="Beta", value="%"),
        ddk.DataCard(id="dc4", width=25, label="Country", value="-"),
    ]),
    ddk.Block(children=[
        ddk.Card(rounded=True,
                 children=[
                     ddk.Graph(
                         id="graph",
                         figure={
                             "data": [
                                 go.Scatter(x=iex.get_prices(
                                     "AAPL", "2015-01-01", "2016-01-01").index,
                                            y=iex.get_prices(
                                                "AAPL", "2015-01-01",
                                                "2016-01-01")["Adj Close"])
                             ],
                             "layout":
                             go.Layout(xaxis={'showgrid': False},
                                       yaxis={'showgrid': False})
                         })
                 ])
    ])
])


@app.callback([
    Output("graph", "figure"),
    Output("dc4", "value"),
    Output("dc3", "value"),
        var_list.append({'label': var, 'value': var})

    vars[set] = var_list

external_stylesheets = ['https://codepen.io./chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__)

app.layout = html.Div([
    #Baro
    html.Div([
        html.Label(['Barometric Pressure']),
        ddk.Card(width=100,
                 children=[ddk.Graph(id='baro-graphic',
                                     figure = px.scatter(data['baro'],
                                                         y=data['baro']['BaroPres'],
                                                         x=data['baro']['time']
                                                        )
                                    )],
                 )
            ]),
    html.Div([
        #html.H3('Column 1'),
        html.Label(['Scientific Data']),
        dcc.Dropdown(
            id="select_sci",
            options=vars['sci'],
            value=vars['sci'][0]['value']
            #multi=True
        ),
        ddk.Card(width=100,
                 children=[ddk.Graph(id='sci-graphic')],
Beispiel #9
0
                ])
            ]),
        ddk.ControlCard(
            width=25,
            children=[
                ddk.ControlItem(children=[
                    dcc.Dropdown(id="dd2", options=time, value="15min")
                ])
            ]),
        ddk.ControlCard(
            width=25,
            children=[
                ddk.ControlItem(
                    children=[dcc.Input(id="Input_Value", value=5)])
            ]),
        ddk.Card(children=[ddk.Graph(id="graph")])
    ])


@app.callback(Output("graph", "figure"), [
    Input("dd1", "value"),
    Input("dd2", "value"),
    Input("Input_Value", "value")
])
def update_graph(dd1, dd2, Input_Value):
    r = requests.get(
        "https://financialmodelingprep.com/api/v3/historical-chart/%s/%s" %
        (dd2, dd1))
    df = pd.DataFrame.from_dict(r.json())
    df["date"] = pd.to_datetime(df["date"])
    df["SMA"] = df["close"].rolling(int(Input_Value)).mean()
Beispiel #10
0
        children=[ddk.ControlItem(children=[dcc.Dropdown(id="dropdown", options=iex.companies, value="AAPL"),
                                            ddk.ControlItem(width=50,children=[dcc.DatePickerRange(id="datepicker",start_date="2015-01-01",end_date="2016-01-01",display_format="YYYY-MM-DD")])])],



        )),
    ddk.Block(children=[ddk.DataCard(id="dc1", width=25, label="Dividend Yield", value="-"),
                        ddk.DataCard(id="dc2", width=25, label="Peg Ratio", value="-"),
                        ddk.DataCard(id="dc3", width=25, label="Beta", value="%"),
                        ddk.DataCard(id="dc4", width=25, label="Country", value="-"),
                        ]),
    ddk.Block(children=[ddk.Card(rounded=True, children=[ddk.Graph(id="graph", figure={
        "data": [go.Scatter(x=iex.get_prices("AAPL","2015-01-01","2016-01-01").index, y=iex.get_prices("AAPL","2015-01-01","2016-01-01")["Adj Close"])], "layout": go.Layout(xaxis={
            'showgrid': False
        },
            yaxis={
                'showgrid': False
            })
    }
                                                                   )])])

])



@app.callback([Output("graph", "figure"),Output("dc4", "value"),
               Output("dc3", "value"),
               Output("dc2", "value"),
               Output("dc1", "value")], [Input("dropdown", "value"),Input("datepicker","start_date"),Input("datepicker","end_date")])
def update_card1(value,start_date,end_date):
    profile = iex.get_company(value)
Beispiel #11
0
def Graphs():
    df_streamtube = ddk.datasets.df_streamtube()
    df_choropleth = ddk.datasets.df_choropleth()
    df_scattergeo = ddk.datasets.df_scattergeo()
    df_iris = ddk.datasets.df_iris()

    x = [1, 2, 3]
    labels = ['Montreal', 'Tofu Bowl', 'Tropical Beaches']
    labels_long = [
        'Montreal', 'New York City', 'Tokyo',
        'Cincinatti', 'Miami', 'London', 'Vancouver'
    ]
    values_long = [1, 2, 3, 1, 5, 6, 7]
    y1 = [3, 1, 2]
    y2 = [4, 10, 4]
    y3 = [5, 2, 3]
    y4 = [9, 3, 8]
    y5 = [10, 5, 12]
    y6 = [11, 8, 10]
    y7 = [1, 2, 1]
    y8 = [5, 3, 1]
    z = [5, 3, 1]
    matrix = [
        [1, 2, 3],
        [4, 1, 2],
        [1, 3, 4]
    ]

    open = [33.0, 33.3, 33.5, 33.0, 34.1]
    high = [33.1, 33.3, 33.6, 33.2, 34.8]
    low = [32.7, 32.7, 32.8, 32.6, 32.8]
    close = [33.0, 32.9, 33.3, 33.1, 33.1]
    dates = [dt(year=2013, month=10, day=10),
             dt(year=2013, month=11, day=10),
             dt(year=2013, month=12, day=10),
             dt(year=2014, month=1, day=10),
             dt(year=2014, month=2, day=10)]

    r = [0.5, 1, 2, 2.5, 3, 4]
    theta = [35, 70, 120, 155, 205, 240]


    datas = [
        [
            {'type': 'scatter', 'x': x, 'y': y1, 'mode': 'lines'},
            {'type': 'scatter', 'x': x, 'y': y2, 'mode': 'lines'},
        ],

        [
            {'type': 'scatter', 'x': x, 'y': y1, 'mode': 'lines'},
            {'type': 'scatter', 'x': x, 'y': y2, 'mode': 'lines'},
            {'type': 'scatter', 'x': x, 'y': y3, 'mode': 'lines'},
            {'type': 'scatter', 'x': x, 'y': y4, 'mode': 'lines'},
        ],

        [
            {'type': 'scatter', 'x': x, 'y': y1, 'mode': 'lines'},
            {'type': 'scatter', 'x': x, 'y': y2, 'mode': 'lines'},
            {'type': 'scatter', 'x': x, 'y': y3, 'mode': 'lines'},
            {'type': 'scatter', 'x': x, 'y': y4, 'mode': 'lines'},
            {'type': 'scatter', 'x': x, 'y': y5, 'mode': 'lines'},
            {'type': 'scatter', 'x': x, 'y': y6, 'mode': 'lines'},
            {'type': 'scatter', 'x': x, 'y': y7, 'mode': 'lines'},
            {'type': 'scatter', 'x': x, 'y': y8, 'mode': 'lines'},
        ],

        [
            {'type': 'scatter', 'x': x, 'y': y1, 'mode': 'markers'},
            {'type': 'scatter', 'x': x, 'y': y2, 'mode': 'markers'},
        ],

        [
            {'type': 'scatter', 'x': x, 'y': y1, 'mode': 'markers'},
            {'type': 'scatter', 'x': x, 'y': y2, 'mode': 'markers'},
            {'type': 'scatter', 'x': x, 'y': y3, 'mode': 'markers'},
            {'type': 'scatter', 'x': x, 'y': y4, 'mode': 'markers'},
        ],

        [
            {'type': 'scatter', 'x': x, 'y': y1, 'mode': 'markers'},
            {'type': 'scatter', 'x': x, 'y': y2, 'mode': 'markers'},
            {'type': 'scatter', 'x': x, 'y': y3, 'mode': 'markers'},
            {'type': 'scatter', 'x': x, 'y': y4, 'mode': 'markers'},
            {'type': 'scatter', 'x': x, 'y': y5, 'mode': 'markers'},
            {'type': 'scatter', 'x': x, 'y': y6, 'mode': 'markers'},
            {'type': 'scatter', 'x': x, 'y': y7, 'mode': 'markers'},
            {'type': 'scatter', 'x': x, 'y': y8, 'mode': 'markers'},
        ],

        [
            {
                'type': 'scatter', 'x': x, 'y': y1, 'marker': {'color': y2},
                'mode': 'markers'
            },
        ],

        [
            {'type': 'scatter', 'x': x, 'y': y1, 'mode': 'lines+markers'},
            {'type': 'scatter', 'x': x, 'y': y2, 'mode': 'lines+markers'},
        ],

        [
            {'type': 'bar', 'x': labels, 'y': y1},
            {'type': 'bar', 'x': labels, 'y': y2},
        ],

        [
            {'type': 'bar', 'x': labels, 'y': y1},
            {'type': 'bar', 'x': labels, 'y': y2},
            {'type': 'bar', 'x': labels, 'y': y3},
            {'type': 'bar', 'x': labels, 'y': y4},
        ],

        [
            {'type': 'bar', 'x': labels, 'y': y1},
            {'type': 'bar', 'x': labels, 'y': y2},
            {'type': 'bar', 'x': labels, 'y': y3},
            {'type': 'bar', 'x': labels, 'y': y4},
            {'type': 'bar', 'x': labels, 'y': y5},
            {'type': 'bar', 'x': labels, 'y': y6},
            {'type': 'bar', 'x': labels, 'y': y7},
            {'type': 'bar', 'x': labels, 'y': y8},
        ],

        [
            {'type': 'scatter', 'x': x, 'y': y1, 'mode': 'lines', 'fill': 'tonexty'},
            {'type': 'scatter', 'x': x, 'y': y2, 'mode': 'lines', 'fill': 'tonexty'},
        ],

        [
            {'type': 'heatmap', 'z': matrix}
        ],

        [
            {'type': 'contour', 'z': matrix}
        ],

        [
            {'type': 'histogram2d', 'x': x, 'y': y1}
        ],

        [
            {'type': 'histogram2dcontour', 'x': x, 'y': y1}
        ],

        [
            {'type': 'pie', 'labels': labels, 'values': y1}
        ],

        [
            {'type': 'pie', 'labels': labels_long, 'values': values_long}
        ],

        [
            {'type': 'box', 'y': y1},
            {'type': 'box', 'y': y2}
        ],

        [
            {'type': 'box', 'y': y1, 'boxpoints': 'all'},
            {'type': 'box', 'y': y2, 'boxpoints': 'all'}
        ],

        [
            {'type': 'violin', 'y': y1},
            {'type': 'violin', 'y': y2}
        ],

        [
            {'type': 'violin', 'y': y1, 'points': 'all'},
            {'type': 'violin', 'y': y2, 'points': 'all'}
        ],

        [
            {'type': 'histogram', 'y': y1}
        ],

        [
            {'type': 'scatter3d', 'x': x, 'y': y1, 'z': z, 'mode': 'markers'},
            {'type': 'scatter3d', 'x': x, 'y': y2, 'z': z, 'mode': 'markers'}
        ],

        [
            {'type': 'scatter3d', 'x': x, 'y': y1, 'z': z, 'mode': 'lines'},
            {'type': 'scatter3d', 'x': x, 'y': y2, 'z': z, 'mode': 'lines'}
        ],

        [
            {'type': 'scatter3d', 'x': x, 'y': y1, 'z': z, 'mode': 'markers+lines'},
            {'type': 'scatter3d', 'x': x, 'y': y2, 'z': z, 'mode': 'markers+lines'}
        ],

        [
            {'type': 'surface', 'z': matrix}
        ],

        [
            {
                'type': 'cone',
                'x': [row[0] for row in cone_data],
                'y': [row[1] for row in cone_data],
                'z': [row[2] for row in cone_data],
                'u': [row[3] for row in cone_data],
                'v': [row[4] for row in cone_data],
                'w': [row[5] for row in cone_data],
            }
        ],

        [
            {
                'type': 'streamtube',
                'x': df_streamtube['x'],
                'y': df_streamtube['y'],
                'z': df_streamtube['z'],
                'u': df_streamtube['u'],
                'v': df_streamtube['v'],
                'w': df_streamtube['w'],
                'sizeref': 0.5
            }
        ],

        [
            {
                'type': 'choropleth',
                'z': df_choropleth['GDP (BILLIONS)'],
                'locations': df_choropleth['CODE'],
                'text': df_choropleth['COUNTRY']
            }
        ],

        [
            {
                'type': 'scattergeo',
                'lon': df_scattergeo['long'],
                'lat': df_scattergeo['lat'],
                'mode': 'markers',
            }
        ],

        [
            {
                'type': 'scattermapbox',
                'lon': df_scattergeo['long'],
                'lat': df_scattergeo['lat'],
                'mode': 'markers',
            }
        ],

        [
            {
                'type': 'candlestick',
                'open': open,
                'high': high,
                'low': low,
                'close': close
            }
        ],

        [
            {
                'type': 'ohlc',
                'open': open,
                'high': high,
                'low': low,
                'close': close
            }
        ],

        [
            {'type': 'scatterternary', 'a': x, 'b': y1, 'c': y2, 'mode': 'markers'},
        ],

        [
            {'type': 'scatterternary', 'a': x, 'b': y1, 'c': y2, 'mode': 'lines'},
        ],

        [
            {'type': 'scatterpolar', 'r': r, 'theta': theta, 'mode': 'markers'},
        ],
        [
            {'type': 'scatterpolar', 'r': r, 'theta': theta, 'mode': 'lines'},
        ],

        [
            dict(
                type='parcoords',
                dimensions=list([
                    dict(range=[0,8],
                        constraintrange=[4,8],
                        label='Sepal Length', values=df_iris['sepal_length']),
                    dict(range=[0,8],
                        label='Sepal Width', values=df_iris['sepal_width']),
                    dict(range=[0,8],
                        label='Petal Length', values=df_iris['petal_length']),
                    dict(range=[0,8],
                        label='Petal Width', values=df_iris['petal_width'])
                ])
            )
        ],

        [
            dict(
                type='sankey',
                node=dict(
                    label=["Nuclear", "Wind Energy", "Thermal", "Bio Conversion", "Airline Industry", "Losses"],
                ),
                link=dict(
                    source=[0, 1, 0, 2, 3, 3],
                    target=[2, 3, 3, 4, 4, 5],
                    value=[8, 4, 2, 8, 4, 2]
                )
            )
        ],

        [
            {
                'type': 'carpet',
                'a': [4, 4, 4, 4.5, 4.5, 4.5, 5, 5, 5, 6, 6, 6],
                'b': [1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3],
                'y': [2, 3.5, 4, 3, 4.5, 5, 5.5, 6.5, 7.5, 8, 8.5, 10],
            }
        ],

        [
            {
                'type': 'contourcarpet',
                'a': [0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3],
                'b': [4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],
                'z': [1, 1.96, 2.56, 3.0625, 4, 5.0625, 1, 7.5625, 9, 12.25, 15.21, 14.0625],
            },
            {
                'type': 'carpet',
                'a': [0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3],
                'b': [4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6],
                'x': [2, 3, 4, 5, 2.2, 3.1, 4.1, 5.1, 1.5, 2.5, 3.5, 4.5],
                'y': [1, 1.4, 1.6, 1.75, 2, 2.5, 2.7, 2.75, 3, 3.5, 3.7, 3.75],
            }
        ]

    ]

    return html.Div([
        ddk.Card(width=25, children=[
            ddk.CardHeader(title=data[0]['type']),
            ddk.Graph(
                id='graph-{}'.format(i),
                figure={
                    'data': data,
                    'layout': {
                        'title': 'Hello World',
                    }
                }
            )
        ])
        for (i, data) in enumerate(datas)
    ])
Beispiel #12
0
import dash
import dash_design_kit as ddk
import plotly.express as px
import pandas as pd

app = dash.Dash(__name__)
server = app.server  # expose server variable for Procfile

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 = ddk.App(
    show_editor=True,
    children=[
        ddk.Header([ddk.Title('Hello Dash')]),
        ddk.Card(children=[
            ddk.CardHeader(
                title='Dash: A Web application framework for Python.'),
            ddk.Graph(figure=fig)
        ])
    ])