Skip to Content
ConceptsVisualizationInteractive Dashboard

Interactive Dashboard

Advanced

Learning Objectives

After completing this recipe, you will be able to:

  • Understand the difference between static and interactive charts
  • Grasp dashboard layout concepts

Note: This Cookbook is a static build site, so interactive elements are replaced with screenshots or static examples.


0. Setup

import pandas as pd import numpy as np import matplotlib.pyplot as plt # Synthetic data for dashboard df = pd.DataFrame({ 'Metric': ['Revenue', 'Cost', 'Profit'], 'Value': [1000, 600, 400] })

1. Dashboard KPI Card Example

Visualize the most commonly used KPI card format in dashboards.

fig, axes = plt.subplots(1, 3, figsize=(15, 4)) colors = ['blue', 'red', 'green'] for i, (metric, value, color) in enumerate(zip(df['Metric'], df['Value'], colors)): ax = axes[i] ax.text(0.5, 0.7, metric, ha='center', va='center', fontsize=20, color='gray') ax.text(0.5, 0.4, f"${value}", ha='center', va='center', fontsize=30, fontweight='bold', color=color) ax.axis('off') ax.set_title(f"KPI: {metric}") # Add border rect = plt.Rectangle((0,0), 1, 1, fill=False, color='gray', lw=2, transform=ax.transAxes) ax.add_patch(rect) plt.suptitle('Dashboard KPI Overview') plt.show()

Dashboard KPI

2. Composite Chart Layout

Implement a dashboard feel by arranging multiple charts.

fig = plt.figure(figsize=(12, 8)) gs = fig.add_gridspec(2, 2) # Top Left: Bar ax1 = fig.add_subplot(gs[0, 0]) ax1.bar(['A', 'B', 'C'], [10, 20, 15], color='skyblue') ax1.set_title('Sales by Category') # Top Right: Line ax2 = fig.add_subplot(gs[0, 1]) ax2.plot([1, 2, 3, 4, 5], [10, 12, 15, 14, 18], 'r-o') ax2.set_title('Trend') # Bottom: Scatter matches width ax3 = fig.add_subplot(gs[1, :]) ax3.scatter(np.random.randn(50), np.random.randn(50), c=np.random.randn(50)) ax3.set_title('Correlation Distribution') plt.tight_layout() plt.show()

Dashboard Layout

Last updated on

šŸ¤–AI ėŖØģ˜ė©“ģ ‘ģ‹¤ģ „ģ²˜ėŸ¼ ģ—°ģŠµķ•˜źø°