Practice Project 2

Data Visualization & Executive Dashboard Project

Design static and interactive charts with Matplotlib, Seaborn, and Plotly, assemble an executive business dashboard, and document data-driven findings.

Domain / Environment
Retail Business / Conda VM
Difficulty
Intermediate (2/5)
Course Module
Data Visualization
Deliverables
Dashboard Plot & HTML Interactive Panel
1. System Architecture & Process Workflow

The diagram below outlines the visualization compilation architecture. The raw sales database is ingested into a Pandas DataFrame, where KPIs are calculated. This structured data is mapped to static Matplotlib/Seaborn layouts (saving a 4-panel dashboard) and passed to Plotly to generate an interactive HTML chart.

Input Data sales_records.csv Date, Category, Sales DF Load 1. Model & Aggregate Pandas groupby() KPI Calculations 2A. Static subplots Seaborn / Matplotlib 2B. Plotly Interactive Express HTML charts Outputs dashboard.png interactive.html KPI indicators
2. Part 1: Step-by-Step Action Items & Key Execution Steps
STEP 1

Activate Python Virtual Environment

Point the terminal execution environment to the course conda sandbox environment.

$ conda activate ds_ai_ml
This command points active library pathways to the virtual sandbox libraries.
STEP 2

Create Project Folders inside Linux VM

Create a dedicated folder for the project files inside your guest VM home folder directory.

$ mkdir -p ~/Projects/data_viz && cd ~/Projects/data_viz
This compiles project files in one isolated directory structure.
STEP 3

Save Mock Sales Records CSV

Write transaction data containing date, category, sales numbers, and discount rates to a local file.

$ nano sales_records.csv
This opens nano editor. Paste the dataset template from Part 2, press **Ctrl + O** and **Enter** to save, and **Ctrl + X** to exit.
STEP 4

Install Visualizations Packages via Pip

Install Seaborn, Plotly, and default dependencies inside the active environment sandbox.

$ pip install seaborn plotly pandas matplotlib openpyxl
This installs scientific plotting extensions, loading components to compile interactive charts.
STEP 5

Create visualizer script file in VS Code

Launch VS Code and create a new script file inside the project workspace folder.

Launch VS Code via terminal "code ." -> Right-click in file tree explorer -> click New File -> Type: generate_dashboard.py -> Press Enter
This registers an empty file `generate_dashboard.py` inside the active directory editor workspace.
STEP 6

Load Python visualization logic

Paste the plotting code into the newly created python script file.

Click generate_dashboard.py -> Paste python code from Part 2 below -> Save file via Ctrl + S
This writes calculations and visual mapping instructions to code files on disk.
STEP 7

Execute script via terminal pane

Run the script using the python engine to compile the visual reports.

$ python generate_dashboard.py
This aggregates columns, saving a 4-pane static visualization dashboard PNG and an interactive Plotly HTML chart.
STEP 8

View Interactive HTML Chart in Firefox

Open the interactive HTML file inside Firefox to test filters and mouse-hover features.

$ firefox interactive_chart.html
This launches Firefox browser inside VM desktop, rendering dynamic responsive Plotly chart graphics.
3. Operational Pipeline Architecture

The flowchart below outlines the dashboard generation pipeline. It traces the steps from database parsing to aggregation, rendering static layouts, compiling HTML files, and verifying outputs in Firefox.

1. Load Data Load CSV rows into Pandas DataFrame pd.read_csv() 2. Aggregate Group by categories and calculate sum df.groupby() 3. Plot Charts Assemble Matplotlib subplots template plt.subplots(2,2) 4. Interactive Compile Plotly Express dynamic html page px.bar().write_html 5. Save files Review dashboard.png and dynamic html Output check
4. Part 2: Complete Deliverable Assets & Production Templates

To compile the visualizations, we need the raw database records and the Python script. Below is a line-by-line explanation of the code, followed by the combined template files.

Step-by-Step Code Construction

Lines 1 - 4

Import Visualization Packages

Include Pandas, Matplotlib, Seaborn, and Plotly modules in the script.

import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import plotly.express as px
These commands load tabular engines, charting frameworks, seaborn themes, and dynamic web visualization components.
Lines 5 - 10

Compute Executive KPI summaries

Load the CSV dataset and compute total sales, total transactions, and averages.

df = pd.read_csv("sales_records.csv") df["Date"] = pd.to_datetime(df["Date"]) total_sales = df["Sales"].sum() total_orders = len(df) avg_value = df["Sales"].mean()
This parses the file, casts column types, and aggregates columns to compute total revenue and purchase metrics.
Lines 11 - 25

Set Matplotlib subplots canvas layout

Set up a 2x2 grid subplots template, configuring canvas dimensions and style themes.

plt.style.use('dark_background') fig, axes = plt.subplots(2, 2, figsize=(16, 10)) fig.suptitle("Executive Sales Performance Dashboard", color="#f8fafc", fontsize=16, fontweight='bold') plt.subplots_adjust(hspace=0.4, wspace=0.3)
This applies a dark theme, initializes the 2x2 layout, sets titles, and configures whitespace margins between subplots.
Lines 26 - 45

Compile Individual Static Charts

Map columns to lines, bars, histograms, and scatter plots, configuring axis labels.

# Line Chart - Trends over Time sales_trend = df.groupby("Date")["Sales"].sum().reset_index() axes[0, 0].plot(sales_trend["Date"], sales_trend["Sales"], color="#38bdf8", linewidth=2.5) axes[0, 0].set_title("Sales Revenue Daily Trend", color="#94a3b8") # Bar Chart - Category Sales cat_sales = df.groupby("Category")["Sales"].sum().reset_index() sns.barplot(data=cat_sales, x="Category", y="Sales", ax=axes[0, 1], palette="Blues_d") axes[0, 1].set_title("Revenue by Product Category", color="#94a3b8") # Histogram - Sales Distribution sns.histplot(df["Sales"], ax=axes[1, 0], kde=True, color="#34d399") axes[1, 0].set_title("Transaction Value Distribution", color="#94a3b8") # Scatter Plot - Discount correlation sns.scatterplot(data=df, x="Discount", y="Sales", ax=axes[1, 1], color="#fbbf24", s=80) axes[1, 1].set_title("Sales Value vs Discount Rate", color="#94a3b8")
This populates the 2x2 grid. It tracks daily trends, draws category totals, models distributions, and visualizes discount correlations.
Lines 46 - 55

Export Static and Compile Plotly Interactive HTML

Save the Matplotlib dashboard to disk and create a dynamic interactive bar chart in HTML.

plt.savefig("dashboard.png", facecolor="#0f172a", edgecolor="none") print("Static dashboard image saved successfully.") # Interactive Plotly Pie Chart fig_interactive = px.pie(df, values="Sales", names="Category", title="Interactive Category Sales Share", color_discrete_sequence=px.colors.sequential.Blues_r) fig_interactive.update_layout(template="plotly_dark", paper_bgcolor="#0f172a") fig_interactive.write_html("interactive_chart.html") print("Interactive HTML chart saved successfully.")
This saves the dashboard layout to disk and builds a dynamic pie chart page, saving it as `interactive_chart.html`.

Production templates

1. Sample Dataset (Save as ~/Projects/data_viz/sales_records.csv):

Date,Product,Category,Sales,Discount 2026-08-01,Notebook Computer,Electronics,1200.00,0.05 2026-08-01,Desk Organizer,Office Supplies,15.50,0.00 2026-08-01,Ergonomic Chair,Furniture,250.00,0.10 2026-08-02,Wireless Mouse,Electronics,25.00,0.00 2026-08-02,LED Desk Lamp,Office Supplies,45.00,0.05 2026-08-02,Office Credenza,Furniture,450.00,0.15 2026-08-03,Mechanical Keyboard,Electronics,89.99,0.00 2026-08-03,Ballpoint Pen Pack,Office Supplies,4.99,0.00 2026-08-03,Standing Desk,Furniture,650.00,0.08 2026-08-04,Wireless Headphones,Electronics,150.00,0.10 2026-08-04,Mesh Wastebasket,Office Supplies,12.50,0.00 2026-08-04,Executive Desk,Furniture,850.00,0.12 2026-08-05,Tablet Computer,Electronics,400.00,0.05 2026-08-05,Heavy Duty Stapler,Office Supplies,22.00,0.00 2026-08-05,Swivel Stool,Furniture,110.00,0.00

2. Python script (Save as ~/Projects/data_viz/generate_dashboard.py):

# generate_dashboard.py - Dashboard visual generator import pandas as pd import matplotlib.pyplot as plt import seaborn as sns import plotly.express as px def main(): print("=== Loading sales transaction dataset ===") df = pd.read_csv("sales_records.csv") df["Date"] = pd.to_datetime(df["Date"]) # Calculate diagnostics total_revenue = df["Sales"].sum() total_tx = len(df) avg_tx = df["Sales"].mean() print(f"Dataset summary loaded:") print(f" - Total Revenue: ${total_revenue:.2f}") print(f" - Transaction count: {total_tx}") print(f" - Avg order value: ${avg_tx:.2f}") # 1. Static Subplots canvas plt.style.use('dark_background') fig, axes = plt.subplots(2, 2, figsize=(16, 10)) fig.suptitle("Executive Sales Performance Dashboard", color="#f8fafc", fontsize=16, fontweight='bold') plt.subplots_adjust(hspace=0.4, wspace=0.3) # Plot 1: Line Chart sales_trend = df.groupby("Date")["Sales"].sum().reset_index() axes[0, 0].plot(sales_trend["Date"], sales_trend["Sales"], color="#38bdf8", marker='o', linewidth=2) axes[0, 0].set_title("Sales Revenue Daily Trend", color="#94a3b8", fontsize=11) axes[0, 0].set_xlabel("Date", color="#64748b") axes[0, 0].set_ylabel("Total Sales ($)", color="#64748b") axes[0, 0].tick_params(colors='#64748b') # Plot 2: Bar Chart cat_sales = df.groupby("Category")["Sales"].sum().reset_index() sns.barplot(data=cat_sales, x="Category", y="Sales", ax=axes[0, 1], palette="Blues_d") axes[0, 1].set_title("Revenue by Product Category", color="#94a3b8", fontsize=11) axes[0, 1].set_xlabel("Category", color="#64748b") axes[0, 1].set_ylabel("Total Sales ($)", color="#64748b") axes[0, 1].tick_params(colors='#64748b') # Plot 3: Histogram sns.histplot(df["Sales"], ax=axes[1, 0], kde=True, color="#34d399", bins=8) axes[1, 0].set_title("Transaction Value Distribution", color="#94a3b8", fontsize=11) axes[1, 0].set_xlabel("Order Value ($)", color="#64748b") axes[1, 0].set_ylabel("Frequency", color="#64748b") axes[1, 0].tick_params(colors='#64748b') # Plot 4: Scatter Plot sns.scatterplot(data=df, x="Discount", y="Sales", ax=axes[1, 1], color="#fbbf24", s=100, alpha=0.8) axes[1, 1].set_title("Sales Value vs Discount Rate", color="#94a3b8", fontsize=11) axes[1, 1].set_xlabel("Discount Rate", color="#64748b") axes[1, 1].set_ylabel("Order Sales ($)", color="#64748b") axes[1, 1].tick_params(colors='#64748b') # Save the static visualization dashboard plot_filename = "dashboard.png" plt.savefig(plot_filename, facecolor="#0f172a", edgecolor="none") print(f"Static dashboard saved successfully: {plot_filename}") # 2. Interactive Chart rendering using Plotly Express print("Compiling interactive Plotly chart...") fig_interactive = px.pie( df, values="Sales", names="Category", title="Interactive Category Sales Share Overview", color_discrete_sequence=px.colors.sequential.Blues_r ) fig_interactive.update_layout( template="plotly_dark", paper_bgcolor="#0f172a", plot_bgcolor="#0f172a", font=dict(family="Manrope", size=11, color="#f8fafc") ) html_filename = "interactive_chart.html" fig_interactive.write_html(html_filename) print(f"Interactive chart saved successfully: {html_filename}") print("=== Data Visualization Project Successfully Complete! ===") if __name__ == "__main__": main()
5. Deliverables Summary

Verify that the following configurations and outputs exist inside your project workspace.

Created Files / Templates

  • ~/Projects/data_viz/sales_records.csv - Raw sales CSV database.
  • ~/Projects/data_viz/generate_dashboard.py - Verification python script file.
  • ~/Projects/data_viz/dashboard.png - 4-panel static visualization dashboard.
  • ~/Projects/data_viz/interactive_chart.html - Interactive pie chart file.

Verification Artifacts / Execution Proof

  • Printed terminal metrics for total revenue and order metrics.
  • A 4-panel graph containing trend line, category bars, value histogram, and discount scatter.
  • Interactive pie chart loading successfully inside Firefox browser, showing hover text.
6. Closing Explanation: Why We Did This & What It Accomplishes

Architectural Intent & Operational Impact

Why We Did This

What This Accomplishes