Complete Diagram Guide

by Peta Team

Complete Diagram Guide

Advanced Features

This chapter covers advanced features and techniques for creating more sophisticated diagrams in Peta.

Title Styling

Custom Titles

All diagram types support custom titles:

RST

1
2   
    
My Custom Title

Start -> End

The title appears at the top of the diagram and helps identify its purpose.

Title Best Practices

  • Keep titles concise (under 10 words)
  • Make titles descriptive
  • Use consistent capitalization
  • Avoid special characters
  • Align titles with content

Diagram Composition

Combining Diagrams

You can use multiple diagrams in a single document to show different aspects:

Example 1: High-Level Flow

System Overview User System Database

Example 2: Detailed Process

Detailed Process User Login Validate Database Show Error

This approach helps organize complex information.

Integration with RST Features

Code Blocks

Combine diagrams with code examples:

Algorithm Flow Input Process Output
PYTHON

1
2   def process(input):
3       result = transform(input)
4       return result
    

Math Formulas

Use diagrams alongside mathematical expressions:

Optimization Process Initial Point Calculate Gradient Update Point Check Convergence

The gradient descent formula:

Article References

Link to related content:

Authentication Flow User System Auth Login Validate
System Architecture Controller Attributes Methods Service Attributes Methods

Python Data Processing

python data-science pandas
2026-01-19T00:00:00

Python Data Processing Example

This snippet demonstrates data processing using pandas and numpy.

PYTHON

1
2    import pandas as pd
3    import numpy as np
4    from sklearn.preprocessing import StandardScaler
5    
6    # Create sample data
7    data = {
8        'name': ['Alice', 'Bob', 'Charlie', 'Diana', 'Eve'],
9        'age': [25, 30, 35, 28, 32],
10        'salary': [50000, 60000, 70000, 55000, 65000],
11        'department': ['IT', 'HR', 'Finance', 'IT', 'Marketing']
12    }
13    
14    # Create DataFrame
15    df = pd.DataFrame(data)
16    print("Original DataFrame:")
17    print(df)
18    
19    # Data preprocessing
20    # 1. Handle missing values
21    df.fillna({'salary': df['salary'].mean()}, inplace=True)
22    
23    # 2. Standardize numerical columns
24    scaler = StandardScaler()
25    numerical_cols = ['age', 'salary']
26    df[numerical_cols] = scaler.fit_transform(df[numerical_cols])
27    
28    # 3. One-hot encode categorical columns
29    df_encoded = pd.get_dummies(df, columns=['department'])
30    
31    print("\nProcessed DataFrame:")
32    print(df_encoded)
33    
34    # 4. Group by department and calculate mean salary
35    dept_salary = df.groupby('department')['salary'].mean()
36    print("\nAverage salary by department:")
37    print(dept_salary)
    
The service layer processes data as shown in the example above.

Styling Considerations

Visual Hierarchy

Create visual hierarchy using:
  • Diagram titles
  • Section headings
  • Different diagram types
  • Spacing and layout
Example:

High-Level Architecture

System Components App Attributes Methods Service Attributes Methods

Implementation Details

Processing Flow Start Process End

Consistency

Maintain consistency across diagrams:
  • Use similar naming conventions
  • Apply consistent styling
  • Follow logical organization
  • Keep diagrams balanced

Performance Considerations

Optimization Tips

  1. Limit complexity: Avoid overly complex diagrams
  2. Use appropriate detail: Match detail level to purpose
  3. Optimize file size: Keep diagrams concise
  4. Test frequently: Verify diagrams render correctly

Build Performance

Diagram rendering is optimized by:
  • Server-side processing
  • Static SVG generation
  • No client-side rendering
  • Efficient caching

Accessibility

Semantic Structure

Use proper RST structure:
RST

1
2   
    
Accessible Flowchart

Start -> End

The title provides context for screen readers.

Descriptive Content

Include descriptive text around diagrams:

This flowchart shows the user registration process. The flow moves from the initial form submission through validation to account creation.

Alternative Text

The diagram title serves as alternative text for accessibility purposes.

Common Use Cases

Documentation

Technical documentation often benefits from diagrams:

API Request Flow Client Gateway Service Database

Presentations

Diagrams enhance presentations:

Project Timeline 01/01 01/08 01/15 01/22 01/29 Phase 1 Phase 2

Education

Educational content uses diagrams for clarity:

Learning Process Student Teacher Question Explanation

Troubleshooting

Common Issues

Build Failures

If the build fails:

  1. Check diagram syntax
  2. Verify diagram type is correct
  3. Ensure proper indentation
  4. Review error messages

Rendering Issues

If diagrams don't render correctly:

  1. Validate syntax against examples
  2. Check for special characters
  3. Verify title formatting
  4. Test with simpler diagrams first

Getting Help

Resources

  • Check syntax examples in this book
  • Review the diagram test article
  • Examine existing diagrams in the codebase
  • Consult the feature documentation

Debugging Tips

  1. Start with minimal diagrams
  2. Add complexity gradually
  3. Test frequently during development
  4. Use the build output for diagnostics
  5. Compare with working examples

Next Steps

The final chapter covers best practices and tips for creating effective diagrams.