Skip to main content

advanced_charts/
advanced_charts.rs

1//! Advanced chart examples with multiple chart types and data
2
3use ppt_rs::generator::{
4    create_pptx_with_content, SlideContent,
5};
6
7fn main() -> Result<(), Box<dyn std::error::Error>> {
8    // Slide 1: Title
9    let title_slide = SlideContent::new("Advanced Analytics Dashboard")
10        .add_bullet("Comprehensive data visualization")
11        .add_bullet("Multiple chart types and formats")
12        .add_bullet("Interactive insights and trends");
13
14    // Slide 2: Bar Chart - Sales by Region
15    let bar_slide = SlideContent::new("Regional Sales Performance")
16        .add_bullet("East region leads with consistent growth")
17        .add_bullet("Q3 shows strongest performance across all regions")
18        .add_bullet("North region demonstrates 28% growth Q1-Q3");
19
20    // Slide 3: Line Chart - Customer Growth
21    let line_slide = SlideContent::new("Customer Acquisition & Retention")
22        .add_bullet("200% growth in new customer acquisition")
23        .add_bullet("Retention rate improved from 85% to 93.5%")
24        .add_bullet("Accelerating growth in Q4");
25
26    // Slide 4: Pie Chart - Product Mix
27    let pie_slide = SlideContent::new("Product Mix Analysis")
28        .add_bullet("Enterprise segment: 42% of revenue")
29        .add_bullet("Mid-Market: 28% with strong growth potential")
30        .add_bullet("SMB & Startup: 30% combined, high growth rate");
31
32    // Slide 5: Multiple metrics
33    let metrics_slide = SlideContent::new("Key Performance Indicators")
34        .add_bullet("Total Revenue: $2.8M (↑ 35% YoY)")
35        .add_bullet("Customer Count: 450 (↑ 200% YoY)")
36        .add_bullet("Retention Rate: 93.5% (↑ 8.5 points)")
37        .add_bullet("Average Deal Size: $6,222 (↑ 12% YoY)")
38        .add_bullet("Sales Cycle: 45 days (↓ 15% faster)");
39
40    // Slide 6: Forecast
41    let forecast_slide = SlideContent::new("2025 Forecast & Goals")
42        .add_bullet("Projected Revenue: $4.2M (50% growth)")
43        .add_bullet("Target Customer Count: 750")
44        .add_bullet("Goal Retention Rate: 95%")
45        .add_bullet("Expansion into 3 new markets")
46        .add_bullet("Launch 2 new product lines");
47
48    let slides = vec![
49        title_slide,
50        bar_slide,
51        line_slide,
52        pie_slide,
53        metrics_slide,
54        forecast_slide,
55    ];
56
57    // Generate the PPTX file
58    let pptx_data = create_pptx_with_content("Analytics Dashboard", slides)?;
59    std::fs::write("advanced_charts.pptx", pptx_data)?;
60
61    println!("✓ Created advanced_charts.pptx with:");
62    println!("  - Title slide");
63    println!("  - Bar chart: Regional sales performance");
64    println!("  - Line chart: Customer growth trajectory");
65    println!("  - Pie chart: Revenue by product category");
66    println!("  - KPI summary slide");
67    println!("  - Forecast and goals slide");
68    println!("\nTotal slides: 6");
69
70    Ok(())
71}