File size: 2,283 Bytes
7ab79fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5293c01
7ab79fb
 
 
 
 
 
 
 
 
5293c01
7ab79fb
 
 
 
 
 
 
 
 
 
de968d2
7ab79fb
 
 
ab9ded2
de968d2
7ab79fb
 
 
5293c01
 
 
 
 
 
 
de968d2
7ab79fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import pandas as pd
import streamlit as st
import plotly.express as px


def streamlit_2columns_metrics_df_shape(df: pd.DataFrame):
    (
        column1name,
        column2name,
    ) = st.columns(2)

    with column1name:
        st.metric(
            label="Rows",
            value=df.shape[0],
            delta=None,
            delta_color="normal",
        )

    with column2name:
        st.metric(
            label="Columns",
            value=df.shape[1],
            delta=None,
            delta_color="normal",
        )


def show_inputted_dataframe(data):
    with st.expander("Input Dataframe:"):
        st.dataframe(data)
        streamlit_2columns_metrics_df_shape(data)


def standard_decomposition_plot(decomposition):

    fig = decomposition.plot()

    (xsize_standard_decomp, ysize_standard_decomp) = streamlit_chart_setting_height_width(
        "Chart Size:", 5, 5, "xsize_standard_decomp", "ysize_standard_decomp")

    fig.set_size_inches(xsize_standard_decomp, ysize_standard_decomp)

    st.pyplot(fig)


def time_series_line_plot(data):
    fig = px.line(
        data
    )
    st.plotly_chart(fig, use_container_width=True)


def time_series_scatter_plot(data):
    fig = px.scatter(data, trendline="ols")
    st.plotly_chart(fig, use_container_width=True)


def time_series_box_plot(data):
    fig = px.box(data, hover_data=['Date'], points="all")
    st.plotly_chart(fig, use_container_width=True)


def time_series_violin_and_box_plot(graph_data):
    fig = px.histogram(graph_data,
                       marginal="violin")
    st.plotly_chart(fig, use_container_width=True)


def streamlit_chart_setting_height_width(
    title: str,
    default_widthvalue: int,
    default_heightvalue: int,
    widthkey: str,
    heightkey: str,
):
    with st.expander(title):

        lbarx_col, lbary_col = st.columns(2)

        with lbarx_col:
            width_size = st.number_input(
                label="Width in inches:",
                value=default_widthvalue,
                key=widthkey,
            )

        with lbary_col:
            height_size = st.number_input(
                label="Height in inches:",
                value=default_heightvalue,
                key=heightkey,
            )
    return width_size, height_size