# Import required libraries import dash from dash import dcc, html from dash.dependencies import Input, Output import plotly.graph_objs as go import pandas as pd # Sample Data: This should be replaced with data extracted from your PDF # For illustration purposes, assume this DataFrame is populated with key figures data data = { 'Year': [2021, 2022, 2023], 'Figure_A': [120, 150, 180], 'Figure_B': [80, 90, 95], 'Figure_C': [200, 210, 220] } # Convert the dictionary into a Pandas DataFrame df = pd.DataFrame(data) # Initialize the Dash app app = dash.Dash(__name__) # App Layout app.layout = html.Div(style={'font-family': 'Arial, sans-serif', 'background-color': '#f9f9f9'}, children=[ html.H1("Key Figures Evolution Dashboard", style={'textAlign': 'center', 'color': '#333'}), # Year Filter Dropdown html.Div([ dcc.Dropdown( id='year-dropdown', options=[{'label': str(year), 'value': year} for year in df['Year'].unique()], value=2023, clearable=False, style={'width': '50%', 'margin': 'auto'} ), ], style={'padding': '10px'}), # First Chart: Figure A Evolution dcc.Graph(id='figure-a-chart'), # Second Chart: Figure B Evolution dcc.Graph(id='figure-b-chart'), # Third Chart: Figure C Evolution dcc.Graph(id='figure-c-chart'), ]) # Callback to update the charts based on selected year @app.callback( [Output('figure-a-chart', 'figure'), Output('figure-b-chart', 'figure'), Output('figure-c-chart', 'figure')], [Input('year-dropdown', 'value')] ) def update_charts(selected_year): # Filter Data by selected year (not really necessary here since it's small data, but for larger data sets) filtered_df = df[df['Year'] <= selected_year] # Figure A fig_a = go.Figure() fig_a.add_trace(go.Scatter(x=filtered_df['Year'], y=filtered_df['Figure_A'], mode='lines+markers', line=dict(color='royalblue', width=3), marker=dict(size=8, symbol='circle'))) fig_a.update_layout(title='Figure A Evolution', xaxis_title='Year', yaxis_title='Figure A', hovermode='x unified', plot_bgcolor='#f9f9f9', paper_bgcolor='#f9f9f9', font=dict(color='#333')) # Figure B fig_b = go.Figure() fig_b.add_trace(go.Bar(x=filtered_df['Year'], y=filtered_df['Figure_B'], marker_color='coral')) fig_b.update_layout(title='Figure B Evolution', xaxis_title='Year', yaxis_title='Figure B', hovermode='x unified', plot_bgcolor='#f9f9f9', paper_bgcolor='#f9f9f9', font=dict(color='#333')) # Figure C fig_c = go.Figure() fig_c.add_trace(go.Scatter(x=filtered_df['Year'], y=filtered_df['Figure_C'], mode='lines+markers', line=dict(color='seagreen', width=3), marker=dict(size=8, symbol='circle'))) fig_c.update_layout(title='Figure C Evolution', xaxis_title='Year', yaxis_title='Figure C', hovermode='x unified', plot_bgcolor='#f9f9f9', paper_bgcolor='#f9f9f9', font=dict(color='#333')) return fig_a, fig_b, fig_c # Run the app if __name__ == '__main__': app.run_server(debug=True)