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)