An interactive visualization dashboard for exploring global coffee production, consumption, import, export, and trade flow data from 1990 to 2019.
This dashboard provides a comprehensive analysis of coffee market dynamics through interactive visualizations built with Dash and Plotly. The dashboard offers detailed insights into production patterns, consumption trends, import/export data, and global trade flows, allowing users to explore coffee market dynamics across different countries and years.
- Production Analysis: Explore coffee production by country, coffee type, and year
- Consumption Analysis: Analyze coffee consumption patterns across countries and time
- Import Analysis: Examine coffee import trends and top importing countries
- Export Analysis: View coffee export data by country and growth rates
- Trade Flow Visualization: Interactive Sankey diagram showing coffee trade flows between countries with filtering by exporter and importer
- Year Slider: Interactive slider (1990-2019) using
dcc.Sliderfor temporal filtering - Coffee Color Theme: Custom color palette with
COFFEE_COLORSandCOFFEE_COLORSCALEvariables
-
Treemap Chart: Country-based production proportional visualization
- Library:
plotly.express.treemap - Data Source:
Coffee_production_modified.csv - Technique: Hierarchical data segmentation by country with dynamic color scaling
- Features: Interactive tooltips, zoom capability
- Library:
-
Countries Table: Ranked list of producing countries
- Implementation: Custom HTML table with
html.Table,html.Tr,html.Tdcomponents - Styling: Alternating row colors, responsive layout
- Data: Sorted by production volume using
sort_valuesin pandas
- Implementation: Custom HTML table with
-
Radial/Pie Chart: Top 10 producers visualization
- Library:
plotly.express.piewith hole parameter for donut effect - Features: "Others" category aggregation for non-top countries
- Data Processing:
get_top_countrieshelper function to extract top producers
- Library:
-
Trend Line Chart: Production across years
- Libraries:
plotly.graph_objects.Scatterfor line and markers - Technique: Polynomial fitting with
np.polyfitfor trend line - Data Processing: Aggregation with
get_annual_totalsfunction
- Libraries:
-
Coffee Types Bar Chart: Production by coffee variety
- Library:
plotly.graph_objects.Bar - Data Processing:
get_coffee_type_totalsfor categorization by Arabica, Robusta, and mixed varieties - Features: Value labels with formatted numbers
- Library:
Similar visualizations as Production tab, using Coffee_domestic_consumption_modified.csv with consumption-specific calculations and titles.
-
Treemap Chart: Country-based import proportional visualization
- Data Source:
Coffee_import.csv - Implementation: Same technique as production treemap with import data
- Data Source:
-
Countries Table: Ranked list of importing countries
- Sorted by import volume using pandas
-
Radial Chart: Top 10 importers visualization
- Same implementation as production but with import data
-
Trend Line Chart: Import volumes across years
- Shows historical import patterns with trend line
-
Treemap Chart: Country-based export proportional visualization
- Data Source:
Coffee_export.csvwith special handling for missing/invalid values - Data Cleaning:
replace(-2147483648, np.nan)to handle placeholder values
- Data Source:
-
Countries Table: Ranked list of exporting countries
- Implementation: Similar to import/production with export-specific data
-
Radial Chart: Top 10 exporters visualization
- Data Processing: Includes filtering for NaN values with
dropna()
- Data Processing: Includes filtering for NaN values with
-
Trend Line Chart: Export volumes across years
- Features: Special handling for missing data in trend calculation with
fillna(0)
- Features: Special handling for missing data in trend calculation with
-
Filter Dropdowns: Country-specific filtering
- Components:
dcc.Dropdownfor exporter and importer selection - Implementation: Dynamic filtering based on selection
- Components:
-
Sankey Diagram: Flow visualization of trade connections
- Library:
plotly.graph_objects.Sankey - Data Source:
synthetic_coffee_trade_flows.csv - Features: Node coloring by type (exporter/importer), dynamic sizing based on quantity
- Library:
-
Top Countries Tables: Exporters and importers rankings
- Implementation: Dynamic table generation based on filtered dataset
The dashboard uses the following CSV data files:
Coffee_production_modified.csv: Production volumes by country and coffee typeCoffee_domestic_consumption_modified.csv: Consumption data by countryCoffee_import.csv: Import volumes by countryCoffee_export.csv: Export volumes by country (with special handling for -2147483648 values)synthetic_coffee_trade_flows.csv: Trade flow connections between countries
Data processing techniques used:
- Pandas operations:
groupby,sort_values,sum,dropna,replace,merge - NumPy functions:
polyfit,poly1d,isnan,percentile - Custom helper functions:
get_top_countries: Extracts top N countries for a specified metric and yearget_annual_totals: Calculates yearly totals with optional coffee type filteringget_coffee_type_totals: Segments data by coffee type (Arabica, Robusta, mixed)get_production_consumption_by_year: Creates comparative yearly data
- Dash: Web application framework for creating interactive dashboards
- Plotly: Interactive visualization library
- Pandas: Data manipulation and analysis
- NumPy: Numerical computations and array operations
- Python 3: Core programming language
sed -i '' 's/\r$//' ./run_final_dashboard_fixes.sh
./run_final_dashboard_fixes.shOr directly with Python:
python coffee_dashboard_revised.py./setup_env.shpip install -r requirements.txtconda env create -f environment.yml
conda activate coffee_dashboardAfter starting the dashboard, open your browser and navigate to:
http://127.0.0.1:8050/
- For best performance, use Chrome, Firefox, or Edge
- The dashboard is responsive and works on both desktop and mobile devices
- All charts include interactive features:
- Hover tooltips with detailed data
- Zoom/pan capabilities
- Click interactions for filtering
- Download as PNG option
coffee_dashboard_revised.py: Main dashboard applicationrun_final_dashboard_fixes.sh: Dashboard launch script- CSV data files: Source data for visualizations
requirements.txtandenvironment.yml: Dependency specifications