---
name: safety-dashboard-viz
description: Generates a 3D safety visualization dashboard for petrochemical plants based on Excel/CSV safety ledgers. Use when the user provides a safety inspection log in CSV/Excel format.
---

# Safety Dashboard Visualizer

This skill converts a CSV/Excel-based safety inspection ledger into a "cool" 3D-style visualization dashboard (HTML file) for the Shanghai Zhangsan Petrochemical Plant.

## Workflow

1.  **Analyze the Ledger**: Read the user-provided safety ledger (CSV/Excel).
2.  **Extract Data**: Parse the following columns/information:
    *   **Department Inspections**: Count of inspections per department (e.g., "科室", "人员检查次数").
    *   **District Distribution**: Count of hazards per district (e.g., "县区", "隐患占比").
    *   **Hazard Types**: Count of each hazard type (e.g., "隐患类型", "隐患个数").
    *   **Prominent Hazards**: Summary text of major hazards (e.g., "总结突出隐患").
3.  **Generate Synthetic Data**: To make the dashboard "cool" and complete, generate the following realistic synthetic data if not present:
    *   **Keywords**: Extract keywords from the summary for a word cloud.
    *   **Trend**: A 7-day hazard rectification trend (random integers).
4.  **Construct JSON**: Create a JSON object matching the `DASHBOARD_DATA` structure.
5.  **Generate HTML**:
    *   Read the `assets/dashboard_template.html` file.
    *   Replace the string `/* DATA_PLACEHOLDER */` with the generated JSON object.
    *   Save the resulting HTML file (e.g., `safety_dashboard_YYYYMMDD.html`).

## Data Structure (JSON)

The JSON object must follow this schema:

```json
{
  "departments": [
    { "name": "Production Dept", "count": 15 },
    { "name": "Safety Dept", "count": 22 },
    { "name": "Logistics", "count": 8 }
  ],
  "districts": [
    { "name": "District A", "count": 12 },
    { "name": "District B", "count": 5 },
    { "name": "District C", "count": 18 }
  ],
  "hazardTypes": [
    { "name": "Fire Safety", "count": 10 },
    { "name": "Electrical", "count": 8 },
    { "name": "Chemical Leak", "count": 5 },
    { "name": "PPE Violation", "count": 12 }
  ],
  "summaries": [
    "High pressure valve leak in District A requires immediate attention.",
    "PPE compliance in Logistics department has improved.",
    "Fire extinguisher inspection pending for District C."
  ],
  "keywords": [
    { "name": "Valve", "value": 50 },
    { "name": "Leak", "value": 45 },
    { "name": "PPE", "value": 40 },
    { "name": "Fire", "value": 35 }
  ],
  "trend": [12, 15, 8, 10, 5, 7, 4]
}
```

## Usage Instructions

1.  **Read** the `assets/dashboard_template.html` file to memory.
2.  **Parse** the user's input CSV/Excel data.
3.  **Construct** the `DASHBOARD_DATA` JSON.
4.  **Replace** `/* DATA_PLACEHOLDER */` in the template content with the JSON.
5.  **Write** the new file to the workspace (e.g., `dashboard_output.html`).
6.  **Present** the file to the user and suggest they open it to view the visualization.

## Sample Data

If the user asks for sample data, provide the content of the CSV files in `assets/`.
