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:
1
2
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
Example 2: Detailed Process
This approach helps organize complex information.
Integration with RST Features
Code Blocks
Combine diagrams with code examples:
1
2 def process(input):
3 result = transform(input)
4 return result
Math Formulas
Use diagrams alongside mathematical expressions:
The gradient descent formula:
Article References
Link to related content:
Python Data Processing
Python Data Processing Example
This snippet demonstrates data processing using pandas and numpy.
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)
Styling Considerations
Visual Hierarchy
Create visual hierarchy using:- Diagram titles
- Section headings
- Different diagram types
- Spacing and layout
High-Level Architecture
Implementation Details
Consistency
Maintain consistency across diagrams:- Use similar naming conventions
- Apply consistent styling
- Follow logical organization
- Keep diagrams balanced
Performance Considerations
Optimization Tips
- Limit complexity: Avoid overly complex diagrams
- Use appropriate detail: Match detail level to purpose
- Optimize file size: Keep diagrams concise
- 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:
1
2
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:
Presentations
Diagrams enhance presentations:
Education
Educational content uses diagrams for clarity:
Troubleshooting
Common Issues
Build Failures
If the build fails:
- Check diagram syntax
- Verify diagram type is correct
- Ensure proper indentation
- Review error messages
Rendering Issues
If diagrams don't render correctly:
- Validate syntax against examples
- Check for special characters
- Verify title formatting
- 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
- Start with minimal diagrams
- Add complexity gradually
- Test frequently during development
- Use the build output for diagnostics
- Compare with working examples
Next Steps
The final chapter covers best practices and tips for creating effective diagrams.