--- name: engineering-report-generator description: Generate engineering analysis reports with interactive Plotly visualizations, standard report sections, and HTML export. Use for creating dashboards, analysis summaries, and technical documentation with charts. version: 1.1.0 category: development related_skills: - data-pipeline-processor - yaml-workflow-executor - parallel-file-processor --- # Engineering Report Generator > Version: 1.1.0 > Category: Development > Last Updated: 2026-01-02 Generate professional engineering analysis reports with interactive visualizations using Plotly and responsive HTML export. ## Quick Start ```python import plotly.express as px import pandas as pd from pathlib import Path from datetime import datetime # Load data df = pd.read_csv("../data/processed/results.csv") # Create visualization fig = px.line(df, x="date", y="value", title="Analysis Results") # Generate HTML report html = f"""
Analysis performed per DNV-RP-C201 using finite element method.
', 'charts': [ {'type': 'heatmap', 'x': 'x_coord', 'y': 'y_coord', 'values': 'stress', 'title': 'Stress Distribution'}, {'type': 'scatter', 'x': 'load', 'y': 'displacement', 'title': 'Load-Displacement Curve'} ], 'conclusions': 'All structural elements satisfy design criteria with safety factor > 1.5
' } ``` ### Example 3: Multi-Panel Dashboard ```python from plotly.subplots import make_subplots def create_dashboard(df: pd.DataFrame, output_path: str): """Create multi-panel analysis dashboard.""" fig = make_subplots( rows=2, cols=2, subplot_titles=('Trend', 'Distribution', 'Comparison', 'Correlation') ) # Add traces to each panel fig.add_trace(go.Scatter(x=df['date'], y=df['value'], mode='lines'), row=1, col=1) fig.add_trace(go.Histogram(x=df['value']), row=1, col=2) fig.add_trace(go.Bar(x=df['category'], y=df['count']), row=2, col=1) fig.add_trace(go.Scatter(x=df['x'], y=df['y'], mode='markers'), row=2, col=2) fig.update_layout(height=800, title_text="Analysis Dashboard") fig.write_html(output_path) return output_path ``` ## Best Practices ### Do 1. Use relative paths from report location for data 2. Include interactive plots only (Plotly, Bokeh, Altair) 3. Apply consistent color schemes across charts 4. Add clear axis labels and titles 5. Include hover data for detailed values 6. Make reports responsive (mobile-friendly) ### Don't 1. Export static matplotlib PNG/SVG images 2. Use absolute file paths 3. Create overly complex visualizations 4. Skip executive summaries 5. Ignore accessibility (color contrast) ### Data Input - Use relative paths from report location - CSV files with clear column headers - Data pre-processed and validated ### HTML Output - Self-contained files (CDN for Plotly) - Responsive design (mobile-friendly) - Print-friendly styling - Accessible color contrast ### File Organization ``` project/ data/ raw/ # Original data processed/ # Analysis-ready CSV reports/ analysis.html # Generated reports scripts/ generate_report.py ``` ## Error Handling ### Common Errors | Error | Cause | Solution | |-------|-------|----------| | `FileNotFoundError` | Data file missing | Verify data path is correct | | `KeyError` | Column not in DataFrame | Check column names match config | | `ValueError` | Data type mismatch | Convert types before plotting | | `Empty figure` | No data after filtering | Validate data before visualization | ### Error Template ```python def safe_generate_report(data_path: str, output_path: str, config: dict) -> dict: """Generate report with error handling.""" try: # Validate data exists if not Path(data_path).exists(): return {'status': 'error', 'message': f'Data file not found: {data_path}'} # Load and validate df = pd.read_csv(data_path) if df.empty: return {'status': 'error', 'message': 'Data file is empty'} # Generate report output = generate_report(data_path, output_path, **config) return {'status': 'success', 'output': output} except Exception as e: return {'status': 'error', 'message': str(e)} ``` ## Execution Checklist - [ ] Data file exists and is not empty - [ ] Column names match chart configuration - [ ] Output directory exists or is created - [ ] All charts have titles and labels - [ ] Report includes executive summary - [ ] Plotly CDN included for interactivity - [ ] Responsive design tested on mobile - [ ] Color contrast meets accessibility standards - [ ] Report file size is reasonable (<10MB) ## Metrics | Metric | Target | Description | |--------|--------|-------------| | Generation Time | <5s | Report creation speed | | File Size | <10MB | HTML report size | | Load Time | <3s | Browser render time | | Chart Count | 1-10 | Optimal visualization count | | Mobile Score | >90 | Lighthouse mobile score | ## Integration ### With YAML Workflow ```yaml task: generate_report input: data_path: data/processed/results.csv output: report_path: reports/analysis.html config: title: "Analysis Report" charts: - type: line x: time y: value ``` ### With Data Pipeline ```python # Pipeline output -> Report input pipeline_results = process_data(raw_data) pipeline_results.to_csv('data/processed/results.csv') generate_report( data_path='data/processed/results.csv', output_path='reports/analysis.html', title='Pipeline Results' ) ``` ## Related Skills - [xlsx](../../document-handling/xlsx/SKILL.md) - Excel data handling - [pdf](../../document-handling/pdf/SKILL.md) - PDF report generation - [data-pipeline-processor](../data-pipeline-processor/SKILL.md) - Data preparation - [yaml-workflow-executor](../yaml-workflow-executor/SKILL.md) - Workflow automation --- ## Version History - **1.1.0** (2026-01-02): Upgraded to SKILL_TEMPLATE_v2 format with Quick Start, Error Handling, Metrics, Execution Checklist, additional examples - **1.0.0** (2024-10-15): Initial release with Plotly visualizations, HTML templates, responsive design