File size: 2,891 Bytes
3165db7
4ad19c2
 
3165db7
4ad19c2
 
3165db7
4ad19c2
 
 
 
3165db7
4ad19c2
3165db7
4ad19c2
 
 
 
 
 
3165db7
4ad19c2
 
 
 
 
3165db7
4ad19c2
 
 
 
 
3165db7
 
4ad19c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3165db7
4ad19c2
 
 
 
 
 
 
3165db7
4ad19c2
 
 
 
 
 
3165db7
 
4ad19c2
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
import panel as pn
import pandas as pd
import plotly.express as px

# Enable Panel extensions
pn.extension(sizing_mode="stretch_width")

# Load data
def load_data():
    file_path = 'digital_identity_data.xlsx'
    return pd.read_excel(file_path)

data = load_data()

# Widgets for filters
country_filter = pn.widgets.CheckBoxGroup(
    name="Select Countries",
    options=data["Country"].unique().tolist(),
    value=data["Country"].unique().tolist(),
    inline=True
)
gender_filter = pn.widgets.CheckBoxGroup(
    name="Select Genders",
    options=data["Gender"].unique().tolist(),
    value=data["Gender"].unique().tolist(),
    inline=True
)
status_filter = pn.widgets.CheckBoxGroup(
    name="Select Account Status",
    options=data["Account Status"].unique().tolist(),
    value=data["Account Status"].unique().tolist(),
    inline=True
)

# Filter data function
def filter_data(countries, genders, statuses):
    filtered = data[
        (data["Country"].isin(countries)) &
        (data["Gender"].isin(genders)) &
        (data["Account Status"].isin(statuses))
    ]
    return filtered

# Dashboard plots
def update_dashboard(countries, genders, statuses):
    filtered_data = filter_data(countries, genders, statuses)

    # Logins by Country
    logins_by_country = filtered_data.groupby("Country")["Number of Logins"].sum().reset_index()
    fig1 = px.bar(logins_by_country, x="Country", y="Number of Logins", title="Logins by Country", color="Country")

    # Session Duration by Gender
    session_duration_by_gender = filtered_data.groupby("Gender")["Session Duration (Minutes)"].mean().reset_index()
    fig2 = px.bar(session_duration_by_gender, x="Gender", y="Session Duration (Minutes)", title="Session Duration by Gender", color="Gender")

    # Data Breaches by Country
    fig3 = px.pie(filtered_data, names="Country", values="Data Breaches Reported", title="Data Breaches by Country")

    # 2FA Usage
    two_fa_usage = filtered_data["2FA Enabled"].value_counts().reset_index()
    two_fa_usage.columns = ["2FA Enabled", "Count"]
    fig4 = px.pie(two_fa_usage, names="2FA Enabled", values="Count", title="2FA Usage")

    return pn.Row(
        pn.Column(pn.pane.Markdown("### Logins by Country"), pn.pane.Plotly(fig1)),
        pn.Column(pn.pane.Markdown("### Session Duration by Gender"), pn.pane.Plotly(fig2)),
        pn.Column(pn.pane.Markdown("### Data Breaches by Country"), pn.pane.Plotly(fig3)),
        pn.Column(pn.pane.Markdown("### 2FA Usage"), pn.pane.Plotly(fig4))
    )

# Interactive panel
dashboard = pn.bind(
    update_dashboard,
    countries=country_filter,
    genders=gender_filter,
    statuses=status_filter
)

# Layout
template = pn.template.BootstrapTemplate(
    title="Digital Identity Dashboard",
    sidebar=[country_filter, gender_filter, status_filter],
    main=[dashboard],
    header_background="#5A9"
)

template.servable()