Пример #1
0
def main():
    # app.layout = html.Div(
    #     [dui.Layout(grid=grid_top),
    #         dui.Layout(grid=grid,controlpanel=controlpanel)
    #     ],style={'height': '100vh','width': '100vw'})

    app.layout = html.Div(dui.Layout(grid=grid_top, controlpanel=controlpanel),
                          style={
                              "height": "100vh",
                              "width": "100vw"
                          })

    app.run_server(debug=True)
Пример #2
0
               graph_id="all-bar",
               menu=menu,
               menu_height=32)
grid.add_graph(col=1, row=5, width=12, height=4, graph_id="total-exports-bar")

grid.add_graph(col=1, row=9, width=4, height=4, graph_id="all-pie")
grid.add_graph(col=5, row=9, width=4, height=4, graph_id="produce-pie")
grid.add_graph(col=9,
               row=9,
               width=4,
               height=4,
               graph_id="animal-pie",
               menu=menu,
               menu_height=32)

app.layout = html.Div(dui.Layout(grid=grid, controlpanel=controlpanel),
                      style={
                          'height': '100vh',
                          'width': '100vw'
                      })


@app.callback(Output('total-exports-pie', 'figure'),
              [Input('state-dropdown', 'value')])
def create_total_exports_pie(state):
    trace = go.Pie(
        labels=df['state'],
        values=df['total exports'],
        textinfo='none',
        marker=dict(
            colors=['red' if x == state else 'grey' for x in df['state']]))
Пример #3
0
        style={'width': '100%', 'float': 'center', 'display': 'inline-block'}
    ),

    html.Div([
        dcc.Graph(id='choro-graphic'),
    ], style={'width': '70%', 'float': 'right', 'display': 'inline-block'})
]))

#grid.add_graph(row=1, col=1, width=2, height=2, graph_id='cd-graphic')

grid.add_graph(row=3, col=1,  width=2, height=1, graph_id='bar-chart')


app.layout = html.Div(
    dui.Layout(
        grid=grid,
        controlpanel=controlpanel
    ),
    style={
        'height': '100vh',
        'width': '100vw'
    }
)	

#### new function 
@app.callback(
    [Output('choro-graphic', 'figure'),
    Output('bar-chart', 'figure')],
    [Input('quick-dropdown', 'value'),
    Input('boro-dropdown', 'value'),
    Input('job-type-dropdown', 'value'),
    Input('year-slider', 'value')]
Пример #4
0
                                           fontSize="15px",
                                           textAlign='center')
                                )  # user will be able to change this emoji
                ]),
                html.Button(  # clicking this does some undetermined thing
                    id="user-settings-button",
                    children="Settings 🔧",
                    n_clicks=0,
                    style=dict(fontSize="20px",
                               backgroundColor='white',
                               border="2px solid darkGreen")),
            ])
        ],
    ))

app.layout = html.Div(dui.Layout(grid=grid),
                      style=dict(width="100vmax",
                                 height="100vmin",
                                 margin='auto',
                                 overflow='auto'))


# show settings div on settings click
@app.callback(Output("user-settings-div", "style"), [
    Input('user-settings-button', 'n_clicks'),
    Input("submit-user-settings-button", "n_clicks")
])
def show_user_settings(n_clicks_settings, n_clicks_submit):
    if n_clicks_settings == 0 and n_clicks_submit == 0:
        return dict(display="none",
                    height="100%",
Пример #5
0
        "height": "100%",
        "width": "100%"
    }))

grid.add_element(
    col=1,
    row=9,
    width=9,
    height=4,
    element=html.Div(style={
        "background-color": "orange",
        "height": "100%",
        "width": "100%"
    }))

grid.add_element(
    col=10,
    row=9,
    width=3,
    height=4,
    element=html.Div(style={
        "background-color": "purple",
        "height": "100%",
        "width": "100%"
    }))

app.layout = dui.Layout(grid=grid, )

if __name__ == "__main__":
    app.run_server(debug=True)
Пример #6
0
recovered_growth_text = formatted_mvmt(recovered_growth, "")
deaths_growth_text = formatted_mvmt(deaths_growth, "")


# Set up the app / server
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)

server = app.server

# Define the grid 
grid = dui.Grid(_id="grid", num_rows=12, num_cols=12, grid_padding=2)

# Define the layout
app.layout = html.Div(
    dui.Layout(
        grid=grid,
    ),
    style={
        'height': '100vh',
        'width': '100vw'
    }
)

app.config.suppress_callback_exceptions = True

# Create a world map and plot cases, recoveries and/or deaths
def generate_map_w_options(df, ref, plot_cases=True, plot_recoveries=True, plot_deaths=True):
    latest_date = df.iloc[len(df)-1][2]
    df = filter_df(df,"Date",latest_date)
    plotted = defaultdict(lambda: False)
    # print(df2)
Пример #7
0
def update_page(n_clicks, ticker):
    grid = dui.Grid(_id="grid", num_rows=12, num_cols=12, grid_padding=0)

    name_output = html.Div([html.H1('LIGHTHAVEN FUND SCREENER')],
                           style={'textAlign': 'center', 'fontSize':20})

    grid.add_element(col=1, row=1, width=12, height=1, element=name_output)

    # Background Color
    grid.add_element(col=1, row=2, width=12, height=11, element=html.Div(
        style={"background-color": "gainsboro", "height": "100%", "width": "100%"}
    ))

    grid.add_element(col=1, row=8, width=6, height=2, element=html.Div(
        style={"background-color": "black", "height": "100%", "width": "100%"}
    ))

    grid.add_element(col=1, row=1, width=12, height=1, element=html.Div(
        style={"background-color": "lightskyblue", "height": "100%", "width": "100%"}
    ))

    # Stock Chart
    start = datetime.datetime.today() - relativedelta(years=5)
    end = datetime.datetime.today()

    try:
        price_data = yf.download(ticker, start, end)
    except:
        return "Could not get data"
    trace_close = go.Scatter(x=list(price_data.index), y=list(price_data.Close), name="close",
                             line=dict(color="#03b1fc"))
    data = [trace_close]
    layout = go.Layout(
        dict(title=ticker + " - HISTORIC STOCK PRICE", showlegend=False),
        margin = {'l': 50, 'r': 50, 't': 50, 'b': 50}
    )
    fig = dict(data=data, layout=layout)
    stock_chart = dcc.Graph(id="Stock Graph", figure=fig)

    grid.add_element(col=1, row=2, width=6, height=4, element=(stock_chart))

    # Company Description
    def find_description(list):
        test = []
        for item in list:
            if (len(item) > 100):
                test.append(item)
        return test
    try:
        page = requests.get('https://finance.yahoo.com/quote/' + ticker + '/profile?p=' + ticker)
        from lxml import html as html2
        tree = html2.fromstring(page.content)
        data = tree.xpath('//p/text()')
        description = find_description(data)[0]
        description = str(description)
        description_output = html.Div([html.H1('COMPANY DESCRIPTION'),
                                       html.P(description)])
    except:
        description_output = html.Div([html.P("Could not find description")])

    grid.add_element(col=8, row=2, width=5, height=6, element=description_output)


    all_info = execute(ticker)
    if (type(all_info) == str):
        not_found = description_output = html.Div([html.H1("Please verify the ticker was entered correctly. Since the information could not be scraped, please manually screen the company.")])
        grid.add_element(col=1, row=7, width=3, height=3, element=not_found)
        return dui.Layout( grid=grid)

    fast_df = all_info[0]
    fast = dash_table.DataTable(
        id='table',
        columns=[{"name": i, "id": i} for i in fast_df.columns],
        data=fast_df.to_dict('records'),
        style_cell = {'textAlign' : 'left'},
        style_header={
            'backgroundColor': 'white',
            'fontWeight': 'bold'
        },
        style_data_conditional=[
            {
                'if': {'row_index': 'odd'},
                'backgroundColor': 'rgb(248, 248, 248)'
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "True"'
                },
                'backgroundColor': '#ACFC6A',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "False"'
                },
                'backgroundColor': '#FF8787',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "Subjective"'
                },
                'backgroundColor': '#fdff82',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS'},
                'width': '25%'
            }
        ],
    )

    grid.add_element(col=1, row=6, width=3, height=3, element=fast)

    stalwart_df = all_info[1]
    stalwart = dash_table.DataTable(
        id='table',
        columns=[{"name": i, "id": i} for i in stalwart_df.columns],
        data=stalwart_df.to_dict('records'),
        style_cell={'textAlign': 'left'},
        style_header={
            'backgroundColor': 'white',
            'fontWeight': 'bold'
        },
        style_data_conditional=[
            {
                'if': {'row_index': 'odd'},
                'backgroundColor': 'rgb(248, 248, 248)'
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "True"'
                },
                'backgroundColor': '#ACFC6A',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "False"'
                },
                'backgroundColor': '#FF8787',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "Subjective"'
                },
                'backgroundColor': '#fdff82',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS'},
                'width': '25%'
            }
        ],
    )

    grid.add_element(col=1, row=9, width=3, height=2, element=stalwart)

    surfer_df = all_info[2]
    surfer = dash_table.DataTable(
        id='table',
        columns=[{"name": i, "id": i} for i in surfer_df.columns],
        data=surfer_df.to_dict('records'),
        style_cell={'textAlign': 'left'},
        style_header={
            'backgroundColor': 'white',
            'fontWeight': 'bold'
        },
        style_data_conditional=[
            {
                'if': {'row_index': 'odd'},
                'backgroundColor': 'rgb(248, 248, 248)'
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "True"'
                },
                'backgroundColor': '#ACFC6A',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "False"'
                },
                'backgroundColor': '#FF8787',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "Subjective"'
                },
                'backgroundColor': '#fdff82',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS'},
                'width': '25%'
            }
        ],
    )

    grid.add_element(col=1, row=11, width=3, height=2, element=surfer)

    dead_df = all_info[3]
    dead = dash_table.DataTable(
        id='table',
        columns=[{"name": i, "id": i} for i in dead_df.columns],
        data=dead_df.to_dict('records'),
        style_cell={'textAlign': 'left'},
        style_header={
            'backgroundColor': 'white',
            'fontWeight': 'bold'
        },
        style_data_conditional=[
            {
                'if': {'row_index': 'odd'},
                'backgroundColor': 'rgb(248, 248, 248)'
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "True"'
                },
                'backgroundColor': '#ACFC6A',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "False"'
                },
                'backgroundColor': '#FF8787',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "Subjective"'
                },
                'backgroundColor': '#fdff82',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS'},
                'width': '25%'
            }
        ],
    )

    grid.add_element(col=4, row=6, width=3, height=3, element=dead)

    fad_df = all_info[4]
    fad = dash_table.DataTable(
        id='table',
        columns=[{"name": i, "id": i} for i in fad_df.columns],
        data=fad_df.to_dict('records'),
        style_cell={'textAlign': 'left'},
        style_header={
            'backgroundColor': 'white',
            'fontWeight': 'bold'
        },
        style_data_conditional=[
            {
                'if': {'row_index': 'odd'},
                'backgroundColor': 'rgb(248, 248, 248)'
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "True"'
                },
                'backgroundColor': '#ACFC6A',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "False"'
                },
                'backgroundColor': '#FF8787',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "Subjective"'
                },
                'backgroundColor': '#fdff82',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS'},
                'width': '25%'
            }
        ],
    )

    grid.add_element(col=4, row=9, width=3, height=2, element=fad)

    hot_df = all_info[5]
    hot = dash_table.DataTable(
        id='table',
        columns=[{"name": i, "id": i} for i in hot_df.columns],
        data=hot_df.to_dict('records'),
        style_cell={'textAlign': 'left'},
        style_header={
            'backgroundColor': 'white',
            'fontWeight': 'bold'
        },
        style_data_conditional=[
            {
                'if': {'row_index': 'odd'},
                'backgroundColor': 'rgb(248, 248, 248)'
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "True"'
                },
                'backgroundColor': '#ACFC6A',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "False"'
                },
                'backgroundColor': '#FF8787',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS',
                    'filter_query': '{STATUS} eq "Subjective"'
                },
                'backgroundColor': '#fdff82',
                'color': 'black',
            },
            {
                'if': {
                    'column_id': 'STATUS'},
                    'width': '25%'
            }
        ],
    )

    grid.add_element(col=4, row=11, width=3, height=2, element=hot)

    fundamentals_df = all_info[6]
    fundamentals = dash_table.DataTable(
        id='table',
        columns=[{"name": i, "id": i} for i in fundamentals_df.columns],
        data=fundamentals_df.to_dict('records'),
        style_cell={'textAlign': 'left'},
        style_header={
            'backgroundColor': 'white',
            'fontWeight': 'bold'
        },
        style_data_conditional=[
            {
                'if': {'row_index': 'odd'},
                'backgroundColor': 'rgb(248, 248, 248)'
            },
            {
                'if': {
                    'column_id': 'STATUS'},
                'width': '25%'
            }
        ]
    )

    grid.add_element(col=8, row=6, width=2, height=2, element=fundamentals)
    
    annual_financials_df = all_info[7]
    annual = dash_table.DataTable(
        id='table',
        columns=[{"name": i, "id": i} for i in annual_financials_df.columns],
        data=annual_financials_df.to_dict('records'),
        style_cell={'textAlign': 'left'},
        style_header={
            'backgroundColor': 'white',
            'fontWeight': 'bold'
        },
        style_data_conditional=[
            {
                'if': {'row_index': 'odd'},
                'backgroundColor': 'rgb(248, 248, 248)'
            },
            {
                'if': {
                    'column_id': 'STATUS'},
                'width': '25%'
            }
        ]
    )
    
    grid.add_element(col=8, row=8, width=5, height=3, element=annual)

    quarterly_financials_df = all_info[8]
    quarterly = dash_table.DataTable(
        id='table',
        columns=[{"name": i, "id": i} for i in quarterly_financials_df.columns],
        data=quarterly_financials_df.to_dict('records'),
        style_cell={'textAlign': 'left'},
        style_header={
            'backgroundColor': 'white',
            'fontWeight': 'bold'
        },
        style_data_conditional=[
            {
                'if': {'row_index': 'odd'},
                'backgroundColor': 'rgb(248, 248, 248)'
            },
            {
                'if': {
                    'column_id': 'STATUS'},
                'width': '25%'
            }
        ]
    )

    grid.add_element(col=8, row=11, width=5, height=2, element=quarterly)

    return dui.Layout( grid=grid)
Пример #8
0
                               'value': "show2"
                           },
                       ],
                       value="show2")
controlpanel.add_element(third, "Third")

grid = dui.Grid(_id="grid", num_rows=12, num_cols=12, grid_padding=10)

grid.add_graph(col=1, row=1, width=12, height=4, graph_id="all-bar")
grid.add_graph(col=1, row=5, width=12, height=4, graph_id="total-exports-bar")

grid.add_graph(col=1, row=9, width=4, height=4, graph_id="all-pie")
grid.add_graph(col=5, row=9, width=4, height=4, graph_id="produce-pie")
grid.add_graph(col=9, row=9, width=4, height=4, graph_id="animal-pie")

app.layout = dui.Layout(grid=grid, controlpanel=controlpanel)


@app.callback(Output('total-exports-pie', 'figure'),
              [Input('state-dropdown', 'value')])
def create_total_exports_pie(state):
    trace = go.Pie(
        labels=df['state'],
        values=df['total exports'],
        textinfo='none',
        marker=dict(
            colors=['red' if x == state else 'grey' for x in df['state']]))
    return go.Figure(
        data=[trace],
        layout={
            'showlegend':
Пример #9
0
def init_dasboard(server):
    dash_app = dash.Dash(server=server,
                         routes_pathname_prefix='/dashapp/',
                         external_stylesheets=[dbc.themes.FLATLY])

    df = pd.DataFrame({
        'month': ['Enero', 'Febrero', 'Marzo', 'Todos'],
        'day': [[
            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
            20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
        ],
                [
                    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
                    18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
                ],
                [
                    1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
                    18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
                ], []],
        'users': [[
            325, 324, 405, 400, 424, 404, 417, 432, 419, 394, 410, 426, 413,
            419, 404, 408, 401, 377, 368, 361, 234, 356, 345, 354, 345, 345,
            378, 344, 342, 412, 453
        ],
                  [
                      432, 419, 394, 410, 426, 413, 419, 404, 408, 401, 377,
                      368, 361, 234, 356, 345, 354, 345, 345, 378, 344, 342,
                      412, 453, 324, 405, 400, 424
                  ],
                  [
                      408, 401, 377, 368, 361, 234, 356, 345, 354, 345, 345,
                      378, 344, 342, 412, 453, 324, 405, 400, 424, 432, 419,
                      394, 410, 426, 413, 419, 404, 408, 401, 377
                  ], []]
    })

    # --------- GRID --------- #

    grid = dui.Grid(_id="grid-1", num_rows=12, num_cols=12, grid_padding=0)

    # BOTÓN FILTROS
    grid.add_element(col=1,
                     row=1,
                     width=12,
                     height=1,
                     element=dbc.Button('FILTROS',
                                        id='filtros-1',
                                        style={
                                            'width': '100%',
                                            'heigth': '100%'
                                        },
                                        className='bg-primary text-white'))

    # MODAL
    grid.add_element(
        col=1,
        row=1,
        width=12,
        height=12,
        element=dbc.Modal(
            id='modal-filtros-1',
            children=[
                dbc.ModalHeader('Filtros'),
                dbc.ModalBody([
                    dbc.Label('Agrupar por'),
                    dbc.RadioItems(id='option-group',
                                   className='d-flex justify-content-around',
                                   value='mensual',
                                   options=[{
                                       'label': 'Mensual',
                                       'value': 'mensual'
                                   }, {
                                       'label': 'Diario',
                                       'value': 'diario'
                                   }]),
                    dbc.Label('Seleccionar mes'),
                    dbc.Select(
                        id='option-month',
                        className=
                        'class="col-sm-10 align-self-center custom-select"',
                        value=0,
                        options=[{
                            'label': df.month[i],
                            'value': i
                        } for i in range(len(df.month))])
                ]),
                dbc.ModalFooter(
                    dbc.Button('CERRAR',
                               id='close-filtros-1',
                               style={'width': '100%'},
                               className='bg-primary text-white'))
            ],
            is_open=False,
            style={'height': '80%'},
            className='p-3',
            size='lg',
            scrollable=True))

    # GRÁFICO 1
    grid.add_graph(col=1, row=2, width=12, height=3, graph_id='graph-1')

    # GRÁFICO 2
    grid.add_graph(col=1, row=5, width=6, height=4, graph_id='graph-2')

    # GRÁFICO 3
    grid.add_graph(col=8, row=5, width=5, height=4, graph_id='graph-3')

    # --------------------------- #

    dash_app.layout = html.Div(children=[
        html.Meta(
            name='viewport',
            content='width=device-width, initial-scale=1, shrink-to-fit=no, \
                maximum-scale=1, minimum-scale=1, user-scalable=0'),
        dui.Layout(grid=grid),
        dcc.Interval(id='interval-users', interval=1 * 5000, n_intervals=0)
    ],
                               style={
                                   'height': '100vh',
                                   'width': '100vw'
                               })

    # --------- EVENTOS --------- #

    @dash_app.callback(Output('graph-1',
                              'figure'), Output('graph-2', 'figure'),
                       Output('graph-3', 'figure'),
                       Input('option-month', 'value'),
                       Input('option-group', 'value'),
                       Input('interval-users', 'n_intervals'))
    def change_month(pos, group, n):
        update_users = randrange(20)
        month_pos = randrange(len(df.month[:-1]))
        day_pos = randrange(len(df.users[month_pos]))

        df.users[month_pos][day_pos] += update_users

        pos = int(pos)
        fig1 = go.Figure()
        fig2 = go.Figure()

        if pos == len(df.month[:-1]):
            total = 0
            for i in range(len(df.month[:-1])):
                total += int(sum(df.users[i]))

            fig1.add_trace(
                go.Indicator(mode='number',
                             value=total,
                             title={'text': 'Usuarios totales'},
                             domain={
                                 'y': [0, 1],
                                 'x': [0, 1]
                             }))

            for i in range(len(df.month[:-1])):
                fig2.add_trace(
                    go.Scatter(x=df.day[i],
                               y=df.users[i],
                               name=df.month[i][:3]))

        else:
            if group == 'mensual':
                if pos == 0:
                    fig1.add_trace(
                        go.Indicator(mode="number+delta",
                                     value=sum(df['users'][pos]),
                                     delta={
                                         'reference': 0,
                                         'valueformat': '.0f'
                                     },
                                     title={
                                         "text":
                                         "Usuarios mensuales en {}".format(
                                             df.month[pos])
                                     },
                                     align='center',
                                     domain={
                                         'y': [0, 1],
                                         'x': [0, 1]
                                     }))
                else:
                    fig1.add_trace(
                        go.Indicator(mode="number+delta",
                                     value=sum(df.users[pos]),
                                     delta={
                                         'reference': sum(df.users[pos - 1]),
                                         'valueformat': '.0f'
                                     },
                                     title={
                                         "text":
                                         "Usuarios mensuales en {}".format(
                                             df.month[pos])
                                     },
                                     align='center',
                                     domain={
                                         'y': [0, 1],
                                         'x': [0, 1]
                                     }))
            else:
                fig1.add_trace(
                    go.Indicator(mode='number+delta',
                                 value=df.users[pos][len(df.users[pos][:-1])],
                                 delta={
                                     'reference':
                                     df.users[pos][len(df.users[pos][:-2])],
                                     'valueformat':
                                     '.0f'
                                 },
                                 title={
                                     'text':
                                     'Usuarios el último día de {}'.format(
                                         df.month[pos])
                                 },
                                 align='center',
                                 domain={
                                     'y': [0, 1],
                                     'x': [0, 1]
                                 }))

            fig2.add_trace(go.Scatter(y=df.users[pos], x=df.day[pos]), )

        fig2.update_layout(plot_bgcolor='white',
                           margin={
                               'l': 0,
                               'r': 30,
                               'b': 50,
                               't': 0,
                               'pad': 0
                           },
                           legend={
                               'orientation': 'h',
                               'yanchor': 'bottom',
                               'y': 1,
                               'xanchor': 'left',
                               'x': 0
                           },
                           modebar={'orientation': 'v'})

        values_pie = []
        labels_pie = []
        for m in range(len(df.month[:-1])):
            values_pie.append(sum(df.users[m]))
            labels_pie.append(df.month[m][:3])

        fig3 = go.Figure(go.Pie(labels=labels_pie, values=values_pie))

        fig3.update_layout(margin={
            'l': 0,
            'r': 0,
            'b': 0,
            't': 0,
            'pad': 0
        },
                           legend={
                               'orientation': 'h',
                               'yanchor': 'bottom',
                               'y': 1.02,
                               'xanchor': 'left',
                               'x': 0
                           },
                           modebar={'orientation': 'v'})

        return fig1, fig2, fig3

    @dash_app.callback(
        Output("modal-filtros-1", "is_open"),
        Input("filtros-1", "n_clicks"),
        Input("close-filtros-1", "n_clicks"),
        State("modal-filtros-1", "is_open"),
    )
    def open_filtros_1(open, close, is_open):
        if open or close:
            return not is_open
        return is_open
Пример #10
0
    wdir, proj, label = sys.argv[1:]
else:
    raise ValueError(
        'You must provide three arguments: wdir, project, and label')

# Dynamically import all callbacks from tab directory
tab_ids = os.listdir('tabs')
for tab_id in tab_ids:
    importlib.import_module('tabs.%s.callbacks' % tab_id)

# Create app layout using tab layouts specified in tab directory
app.layout = html.Div(
    dcc.Tabs(id='tabs',
             value='Database',
             content_style=TAB_STYLE,
             children=[
                 dcc.Tab(label=tab_id.capitalize(),
                         value=tab_id.capitalize(),
                         children=[
                             dui.Layout(grid=importlib.import_module(
                                 'tabs.%s.layout' % tab_id).get_grid(),
                                        controlpanel=importlib.import_module(
                                            'tabs.%s.layout' %
                                            tab_id).get_control_panel(
                                                wdir, proj, label))
                         ]) for tab_id in tab_ids
             ]))

if __name__ == '__main__':
    app.run_server(host='127.0.0.1', debug=True)
Пример #11
0
    element=html.Div(
        dash_table.DataTable(id="metrics"),
        style={"margin-left": "30px", "width": "70%", "align-items": "center"},
    ),
)

grid.add_graph(col=4, row=1, width=4, height=4, graph_id="factor-graph")
grid.add_graph(col=8, row=1, width=4, height=4, graph_id="ohlc-graph")
grid.add_graph(col=4, row=4, width=4, height=5, graph_id="ticker-vs-bm")
grid.add_graph(col=8, row=4, width=4, height=5, graph_id="rolling_sharpe")
grid.add_graph(col=4, row=8, width=4, height=5, graph_id="drawdown")
grid.add_graph(col=8, row=8, width=4, height=5, graph_id="heatmap")


layout = html.Div(
    dui.Layout(grid=grid),
    style={"height": "100vh", "width": "100vw", "background-color": "white"},
)



# html.Div(dcc.Graph(id="monthly_returns")),



# Calculate Factors and update factor graph only.
@app.callback(
    [Output("factor-graph", "figure"), Output("stock-ticker", "options")],
    [Input("quarter-slider", "value"), Input("stock-ticker", "value")],
)
def update_figure_main(