Py.Cafe

zakhtar/

conflict-exposure-calculator

Conflict Exposure Calculator

DocsPricing
  • assets/
  • app.py
  • requirements.txt
app.py
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
import dash
from dash import dcc, html
import plotly.express as px
import geopandas as gpd

# Load sample map data (replace with actual data)
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
fig = px.choropleth(world, 
                    locations='iso_a3', 
                    color='pop_est',
                    hover_name='name',
                    projection='mercator')

# Initialize the Dash app
app = dash.Dash(__name__)

app.layout = html.Div([
    html.H1("Conflict Exposure Calculator"),
    
    html.Div([
        html.P("The Conflict Exposure Calculator shows the number of people exposed to conflict "
               "in the selected area and time period. Use the filter options to choose a geographic "
               "location where people are exposed, the type of conflict they are exposed to, the types "
               "of actors involved in the events, and/or the time period."),
        
        html.Label("What event categories or types are you interested in?"),
        dcc.Dropdown(
            options=[
                {'label': 'All Event Types', 'value': 'all'},
                {'label': 'Armed Conflict', 'value': 'conflict'},
                {'label': 'Political Unrest', 'value': 'political'}
            ],
            value='all',
            clearable=False
        ),
        
        html.Label("What level of aggregation are you interested in?"),
        dcc.Dropdown(
            options=[
                {'label': 'Country', 'value': 'country'},
                {'label': 'Region', 'value': 'region'}
            ],
            value='country',
            clearable=False
        ),
        
        html.Label("Are you interested in specific:"),
        dcc.Checklist(
            options=[
                {'label': 'Actor Types', 'value': 'actor_types'},
                {'label': 'Actors', 'value': 'actors'}
            ]
        ),
        
        html.Label("Select a country or countries to get started."),
        dcc.Dropdown(
            options=[
                {'label': 'Nigeria', 'value': 'Nigeria'},
                {'label': 'Sudan', 'value': 'Sudan'}
            ],
            placeholder="Must make a selection"
        ),

        html.Label("Do you want to filter events within a certain date range? Defaults to previous 12 months."),
        dcc.DatePickerRange(
            start_date='2024-01-17',
            end_date='2025-01-17'
        ),

        html.Button("Click to Apply", id="apply-button"),
        html.Br(),
        html.A("Reset Filters", href="#", style={'color': 'blue', 'text-decoration': 'underline'})
    ], style={'width': '40%', 'display': 'inline-block', 'verticalAlign': 'top', 'padding': '20px'}),

    html.Div([
        dcc.Graph(figure=fig)
    ], style={'width': '58%', 'display': 'inline-block', 'verticalAlign': 'top'})
])

if __name__ == '__main__':
    app.run_server(debug=True)