Пример #1
0
            def update_dropdowns_years_options(df_in, aux):
                """
                    Updates the dropdowns with the years
                """

                df = u.uos.b64_to_df(df_in)
                return lay.get_options(df[c.cols.YEAR].unique().tolist())
Пример #2
0
 def get_body(self):
     return [
         lay.card(dcc.Graph(id="plot_evol", config=c.dash.PLOT_CONFIG)),
         lay.card([
             dcc.Graph(id="plot_evo_detail", config=c.dash.PLOT_CONFIG),
             dbc.RadioItems(
                 id="radio_evol_type",
                 options=lay.get_options(
                     [c.names.EXPENSES, c.names.INCOMES]),
                 value=self.def_type,
                 inline=True,
             ),
         ]),
         lay.get_dummy_div("evo_aux"),
     ]
Пример #3
0
 def get_body(self):
     return [
         lay.card(
             dcc.Graph(
                 id="plot_evol",
                 config=c.dash.PLOT_CONFIG,
                 figure=plots.plot_timeserie(DFS[c.dfs.TRANS],
                                             c.dash.DEFAULT_SMOOTHING,
                                             self.def_tw),
             )),
         lay.card([
             dcc.Graph(
                 id="plot_evo_detail",
                 config=c.dash.PLOT_CONFIG,
                 figure=plots.plot_timeserie_by_categories(
                     DFS[c.dfs.TRANS],
                     DFS[c.dfs.CATEG],
                     c.dash.DEFAULT_SMOOTHING,
                     self.def_type,
                     self.def_tw,
                 ),
             ),
             dbc.RadioItems(
                 id="radio_evol_type",
                 options=lay.get_options(
                     [c.names.EXPENSES, c.names.INCOMES]),
                 value=self.def_type,
                 inline=True,
             ),
         ]),
         lay.card(
             dcc.Graph(
                 id="plot_evo_savings",
                 config=c.dash.PLOT_CONFIG,
                 figure=plots.plot_savings_ratio(DFS[c.dfs.TRANS],
                                                 c.dash.DEFAULT_SMOOTHING,
                                                 self.def_tw),
             )),
     ]
Пример #4
0
    def get_body(self):
        body = []

        # Add plots and dropdowns
        # One row default with all data, the other with last year
        for num, myears in enumerate([self.all_years, self.last_year_as_list]):

            body.append(
                lay.card([
                    html.Div(
                        dcc.Dropdown(
                            id="drop_pie_{}".format(num),
                            multi=True,
                            options=lay.get_options(self.all_years),
                            # prevent long list selected
                            value=myears if myears != self.all_years else None,
                        )),
                    lay.two_columns([
                        dcc.Graph(
                            id="plot_pie_{}_{}".format(num, c.names.INCOMES),
                            config=c.dash.PLOT_CONFIG,
                            figure=plots.get_pie(DFS[c.dfs.TRANS],
                                                 DFS[c.dfs.CATEG],
                                                 c.names.INCOMES, myears),
                        ),
                        dcc.Graph(
                            id="plot_pie_{}_{}".format(num, c.names.EXPENSES),
                            config=c.dash.PLOT_CONFIG,
                            figure=plots.get_pie(DFS[c.dfs.TRANS],
                                                 DFS[c.dfs.CATEG],
                                                 c.names.EXPENSES, myears),
                        ),
                    ]),
                ]))

        return body
Пример #5
0
class Page(lay.AppPage):
    """ Page Comparison """

    link = c.dash.LINK_COMPARISON
    radio_opt = lay.get_options(
        [c.names.INCOMES, c.names.EXPENSES, c.names.EBIT])

    def __init__(self, app):
        super().__init__([c.dash.INPUT_CATEGORIES, c.dash.INPUT_SMOOTHING])

        @app.callback(
            [Output(f"plot_comp_{x}", "figure") for x in list("12")],
            [
                Input("global_df", "children"),
                Input("input_categories", "value"),
                Input("input_smoothing", "value"),
                Input("radio_comp_1", "value"),
                Input("radio_comp_2", "value"),
                Input("comp_aux", "children"),
            ],
        )
        # pylint: disable=unused-variable,unused-argument
        def update_ts_grad_1(df_in, categories, avg_month, type_trans_1,
                             type_trans_2, aux):
            """
                Updates the timeserie gradient plot

                Args:
                    df_in:      transactions dataframe
                    categories: categories to use
                    avg_month:  month to use in rolling average
                    type_trans_1: expenses/incomes/ebit plot 1
                    type_trans_2: expenses/incomes/ebit plot 2
            """

            df = u.uos.b64_to_df(df_in)
            df = u.dfs.filter_data(df, categories)

            return (
                plots.ts_gradient(df, type_trans_1, avg_month),
                plots.ts_gradient(df, type_trans_2, avg_month),
            )

    def get_body(self):
        return [
            lay.card([
                dcc.Graph(id="plot_comp_1", config=c.dash.PLOT_CONFIG),
                dbc.RadioItems(
                    id="radio_comp_1",
                    options=self.radio_opt,
                    value=c.names.INCOMES,
                    inline=True,
                ),
            ]),
            lay.card([
                dcc.Graph(id="plot_comp_2", config=c.dash.PLOT_CONFIG),
                dbc.RadioItems(
                    id="radio_comp_2",
                    options=self.radio_opt,
                    value=c.names.EXPENSES,
                    inline=True,
                ),
            ]),
            lay.get_dummy_div("comp_aux"),
        ]
Пример #6
0
    def get_body(self):
        body = [
            lay.card(
                dcc.Graph(
                    id="plot_invest_total_worth",
                    config=c.dash.PLOT_CONFIG,
                    figure=plots.total_worth_plot(DFS[c.dfs.LIQUID],
                                                  DFS[c.dfs.WORTH],
                                                  c.dash.DEFAULT_SMOOTHING),
                )),
            lay.card([
                dcc.Graph(
                    id="plot_invest_passive_income",
                    config=c.dash.PLOT_CONFIG,
                    figure=plots.passive_income_vs_expenses(
                        DFS[c.dfs.WORTH],
                        DFS[c.dfs.TRANS],
                        c.dash.DEFAULT_SMOOTHING,
                        self.def_smooth,
                    ),
                ),
                dbc.RadioItems(
                    id="radio_invest_smooth",
                    options=[
                        {
                            "label": "Don't smooth",
                            "value": False
                        },
                        {
                            "label": "Smooth passive income",
                            "value": True
                        },
                    ],
                    value=self.def_smooth,
                    inline=True,
                ),
            ]),
            lay.card(
                dcc.Graph(
                    id="plot_invest_performance",
                    config=c.dash.PLOT_CONFIG,
                    figure=plots.total_worth_plot(DFS[c.dfs.INVEST],
                                                  DFS[c.dfs.WORTH],
                                                  c.dash.DEFAULT_SMOOTHING),
                )),
            lay.card([
                dcc.Graph(
                    id="plot_invest_detail",
                    config=c.dash.PLOT_CONFIG,
                    figure=plots.invest_evolution_plot(
                        DFS[c.dfs.INVEST], c.dash.DEFAULT_SMOOTHING),
                ),
                dbc.RadioItems(
                    id="radio_invest_wor_inv",
                    options=lay.get_options([c.names.WORTH, c.names.INVESTED]),
                    value=c.names.WORTH,
                    inline=True,
                ),
            ]),
        ]

        return body
Пример #7
0
class Page(lay.AppPage):
    """ Page Comparison """

    link = c.dash.LINK_COMPARISON
    radio_opt = lay.get_options(
        [c.names.INCOMES, c.names.EXPENSES, c.names.EBIT])

    def __init__(self, app):
        super().__init__([c.dash.INPUT_CATEGORIES, c.dash.INPUT_SMOOTHING])

        @app.callback(
            [Output(f"plot_comp_{x}", "figure") for x in list("12")],
            [
                Input("input_categories", "value"),
                Input("input_smoothing", "value"),
                Input("radio_comp_1", "value"),
                Input("radio_comp_2", "value"),
            ],
        )
        # pylint: disable=unused-variable,unused-argument
        def update_plots(categories, avg_month, type_trans_1, type_trans_2):
            """
                Updates the plots

                Args:
                    categories: categories to use
                    avg_month:  month to use in time average
                    type_trans_1: expenses/incomes/ebit plot 1
                    type_trans_2: expenses/incomes/ebit plot 2
            """

            df = u.filter_data(DFS[c.dfs.TRANS], categories)
            return (
                plots.ts_gradient(df, type_trans_1, avg_month),
                plots.ts_gradient(df, type_trans_2, avg_month),
            )

    def get_body(self):
        return [
            lay.card([
                dcc.Graph(
                    id="plot_comp_1",
                    config=c.dash.PLOT_CONFIG,
                    figure=plots.ts_gradient(DFS[c.dfs.TRANS], c.names.INCOMES,
                                             c.dash.DEFAULT_SMOOTHING),
                ),
                dbc.RadioItems(
                    id="radio_comp_1",
                    options=self.radio_opt,
                    value=c.names.INCOMES,
                    inline=True,
                ),
            ]),
            lay.card([
                dcc.Graph(
                    id="plot_comp_2",
                    config=c.dash.PLOT_CONFIG,
                    figure=plots.ts_gradient(DFS[c.dfs.TRANS],
                                             c.names.EXPENSES,
                                             c.dash.DEFAULT_SMOOTHING),
                ),
                dbc.RadioItems(
                    id="radio_comp_2",
                    options=self.radio_opt,
                    value=c.names.EXPENSES,
                    inline=True,
                ),
            ]),
        ]
Пример #8
0
def update_carriers(origin, dest, direct, past):
    """ Update the carriers list """

    return get_options(get_carriers(origin, dest, direct, past))