## UltraCanvas Sankey Diagram Plugin – Comprehensive Programmer’s Manual

## Version: 1.0.0
## Last Modified: 2025-09-18
## Author: UltraCanvas Framework

—

## Table of Contents

1. [Overview](#overview)
2. [Architecture](#architecture)
3. [Feature List](#feature-list)
4. [Core Data Structures](#core-data-structures)
5. [Configuration Parameters](#configuration-parameters)
6. [Rendering Pipeline](#rendering-pipeline)
7. [Interactive Features](#interactive-features)
8. [Background Graphics Support](#background-graphics-support)
9. [API Reference](#api-reference)
10. [Usage Examples](#usage-examples)
11. [Advanced Configuration](#advanced-configuration)
12. [Integration Guide](#integration-guide)
13. [Performance Optimization](#performance-optimization)
14. [Troubleshooting](#troubleshooting)

—

## Overview

The UltraCanvas Sankey Diagram Plugin provides comprehensive support for creating, rendering, and interacting with Sankey diagrams within the UltraCanvas framework. Sankey diagrams are flow diagrams where the width of arrows is proportional to the flow quantity, commonly used for visualizing energy flows, material flows, cost breakdowns, and data transitions.

### Key Capabilities
– **Multi-format Support**: JSON, CSV, XML data sources
– **Interactive Rendering**: Zoom, pan, selection, hover effects
– **Background Graphics**: Full support for background images and patterns
– **Export Options**: SVG, PNG, PDF, EPS output formats
– **Real-time Updates**: Live data binding and animation support
– **Cross-platform**: Windows, Linux, macOS compatibility

—

## Architecture

The Sankey diagram implementation extends the UltraCanvas diagram rendering system:

“`
UltraCanvasDiagramElement
├── SankeyDiagramRenderer (IDiagramRenderer)
├── SankeyDataProcessor
├── SankeyLayoutEngine
├── SankeyInteractionManager
└── SankeyRenderContext
“`

### Framework Integration
– **Base Class**: `UltraCanvasElement` with `StandardProperties`
– **Rendering**: Uses unified `IRenderContext` system
– **Events**: `UCEvent` handling for all interactions
– **Threading**: Safe async rendering with `std::future`

—

## Feature List

### 📊 Data Management Features
– **Multi-source Data Loading**: CSV, JSON, XML, direct API
– **Real-time Data Binding**: Live updates from data sources
– **Data Validation**: Automatic flow consistency checking
– **Large Dataset Support**: Efficient handling of 10,000+ nodes
– **Custom Data Formatting**: User-defined value formatters

### 🎨 Visual Rendering Features
– **Adaptive Flow Rendering**: Proportional flow widths
– **Color Theming**: Gradient flows, categorical colors, custom palettes
– **Node Styling**: Custom shapes, sizes, labels, icons
– **Background Graphics**: Images, patterns, gradients
– **Anti-aliasing**: Smooth curve rendering
– **High-DPI Support**: Sharp rendering on retina displays

### 🖱️ Interactive Features
– **Zoom and Pan**: Mouse wheel and drag controls
– **Node Selection**: Single and multi-select with keyboard modifiers
– **Flow Highlighting**: Hover effects and path tracing
– **Dynamic Filtering**: Show/hide flows by value or category
– **Context Menus**: Right-click actions on nodes and flows
– **Tooltips**: Rich HTML tooltip content

### 📤 Export and Integration
– **Multiple Output Formats**: SVG, PNG, PDF, EPS, Base64
– **Print Support**: Optimized layouts for printing
– **Clipboard Integration**: Copy diagram or data
– **Animation Export**: GIF/WebP animated sequences
– **Web Integration**: HTML embed codes

### ⚡ Performance Features
– **Caching System**: Intelligent render caching
– **Level-of-Detail**: Automatic simplification for performance
– **Async Rendering**: Non-blocking diagram generation
– **Memory Management**: Efficient large dataset handling
– **GPU Acceleration**: Hardware-accelerated rendering where available

—

## Core Data Structures

### SankeyNode Structure
“`cpp
struct SankeyNode {
std::string nodeId; // Unique identifier
std::string label; // Display name
Point2D position; // Layout position (auto or manual)
Size2D size; // Node dimensions
Color fillColor; // Node fill color
Color borderColor; // Node border color
double borderWidth; // Border thickness
std::string icon; // Optional icon path
std::string tooltip; // Tooltip content
bool visible; // Visibility flag
bool selectable; // Can be selected
std::string category; // Grouping category
std::unordered_map customProperties;
};
“`

### SankeyFlow Structure
“`cpp
struct SankeyFlow {
std::string flowId; // Unique identifier
std::string sourceNodeId; // Source node reference
std::string targetNodeId; // Target node reference
double value; // Flow magnitude
std::string label; // Optional flow label
Color color; // Flow color
double opacity; // Flow transparency (0.0-1.0)
std::string pattern; // Flow pattern (solid, dashed, dotted)
bool animated; // Enable flow animation
double animationSpeed; // Animation speed multiplier
std::string tooltip; // Tooltip content
bool visible; // Visibility flag
std::string category; // Grouping category
std::unordered_map customProperties;
};
“`

### SankeyDiagramData Container
“`cpp
class SankeyDiagramData {
public:
std::vector nodes;
std::vector flows;
SankeyLayoutConfig layoutConfig;
SankeyStyleConfig styleConfig;
std::string title;
std::string description;
std::unordered_map metadata;

// Data manipulation methods
bool AddNode(const SankeyNode& node);
bool AddFlow(const SankeyFlow& flow);
bool RemoveNode(const std::string& nodeId);
bool RemoveFlow(const std::string& flowId);
bool ValidateData(std::vector& errors);
void ClearAll();
};
“`

—

## Configuration Parameters

### Layout Configuration
“`cpp
struct SankeyLayoutConfig {
// Layout Algorithm
LayoutAlgorithm algorithm = LayoutAlgorithm::Force; // Force, Layered, Manual

// Spacing Parameters
double nodeSpacing = 50.0; // Horizontal spacing between node columns
double levelSpacing = 30.0; // Vertical spacing within columns
double flowSpacing = 2.0; // Minimum spacing between flows

// Node Sizing
double minNodeWidth = 20.0; // Minimum node width
double maxNodeWidth = 200.0; // Maximum node width
double nodeHeight = 15.0; // Default node height
NodeSizeMode sizeMode = NodeSizeMode::Proportional; // Fixed, Proportional, Custom

// Flow Rendering
double minFlowWidth = 1.0; // Minimum flow width
double maxFlowWidth = 100.0; // Maximum flow width
FlowCurvature curvature = FlowCurvature::Natural; // None, Gentle, Natural, Strong

// Layout Constraints
bool allowOverlap = false; // Allow node overlap
bool preserveNodeOrder = true; // Maintain input node order
int maxIterations = 1000; // Layout algorithm iterations
double convergenceThreshold = 0.1; // Layout convergence criteria

// Advanced Options
std::unordered_map customParameters;
};
“`

### Style Configuration
“`cpp
struct SankeyStyleConfig {
// Color Schemes
ColorScheme colorScheme = ColorScheme::Category10;
std::vector customColors;
bool useGradients = true;
GradientDirection gradientDirection = GradientDirection::FlowDirection;

// Node Appearance
double nodeCornerRadius = 5.0; // Rounded corner radius
double nodeBorderWidth = 1.0; // Default border width
Color defaultNodeColor = Colors::LightGray;
Color defaultBorderColor = Colors::DarkGray;

// Flow Appearance
FlowRenderStyle flowStyle = FlowRenderStyle::Bezier;
double flowOpacity = 0.8; // Default flow transparency
bool showFlowLabels = false; // Display flow values
double flowLabelSize = 10.0; // Flow label font size

// Text Styling
std::string fontFamily = “Arial”;
double nodeLabelSize = 12.0; // Node label font size
Color textColor = Colors::Black;
TextAlignment labelAlignment = TextAlignment::Center;

// Visual Effects
bool enableShadows = true; // Drop shadows
Color shadowColor = Color(0, 0, 0, 50);
Point2D shadowOffset = Point2D(2, 2);
bool enableAnimation = true; // Enable animations
double animationDuration = 1.0; // Animation duration in seconds

// Advanced Styling
std::unordered_map cssProperties;
};
“`

### Rendering Configuration
“`cpp
struct SankeyRenderConfig : public DiagramRenderConfig {
// Sankey-specific rendering options
bool enableLevelOfDetail = true; // Automatic detail reduction
double detailThreshold = 0.5; // Minimum zoom for full detail
bool enableFlowAnimation = true; // Animated flow particles
int animationParticles = 20; // Number of animation particles

// Background Support
std::string backgroundImage; // Background image path
BackgroundMode backgroundMode = BackgroundMode::Stretch;
double backgroundOpacity = 1.0; // Background transparency

// Quality Settings
AntiAliasing antiAliasingLevel = AntiAliasing::High;
bool useSubPixelRendering = true; // Sharp text rendering

// Performance Options
bool enableGPUAcceleration = true;
int maxRenderThreads = 4; // Parallel rendering threads

static SankeyRenderConfig HighQuality() {
SankeyRenderConfig config;
config.dpi = 600;
config.quality = 95;
config.antiAliasingLevel = AntiAliasing::Ultra;
config.enableFlowAnimation = true;
return config;
}

static SankeyRenderConfig Performance() {
SankeyRenderConfig config;
config.dpi = 150;
config.enableLevelOfDetail = true;
config.enableFlowAnimation = false;
config.enableGPUAcceleration = true;
return config;
}
};
“`

—

## Rendering Pipeline

### 1. Data Processing Stage
– **Data Validation**: Check node/flow consistency
– **Flow Aggregation**: Combine duplicate flows
– **Value Normalization**: Scale flow values for rendering
– **Category Processing**: Group nodes and flows by category

### 2. Layout Calculation Stage
– **Node Positioning**: Calculate optimal node positions
– **Flow Routing**: Determine flow paths and curves
– **Collision Detection**: Resolve overlaps and intersections
– **Iteration Convergence**: Refine layout until stable

### 3. Style Application Stage
– **Color Assignment**: Apply color schemes to elements
– **Size Calculation**: Determine final element dimensions
– **Text Layout**: Position labels and tooltips
– **Effect Processing**: Apply shadows, gradients, patterns

### 4. Rendering Stage
– **Background Rendering**: Draw background graphics
– **Flow Rendering**: Render flow paths with curves
– **Node Rendering**: Draw nodes with styling
– **Label Rendering**: Add text labels and values
– **Effect Rendering**: Apply visual effects and animations

—

## Interactive Features

### Mouse Interactions
“`cpp
// Mouse event handling configuration
struct SankeyInteractionConfig {
bool enableZoom = true; // Mouse wheel zooming
bool enablePan = true; // Middle-click panning
bool enableSelection = true; // Click selection
bool enableHover = true; // Hover highlighting
bool enableContextMenu = true; // Right-click menus

// Selection behavior
SelectionMode selectionMode = SelectionMode::Multiple;
bool selectFlowsWithNodes = true; // Auto-select connected flows

// Hover behavior
HoverHighlight hoverStyle = HoverHighlight::Glow;
double hoverIntensity = 1.5; // Highlight intensity multiplier

// Animation settings
double interactionAnimationSpeed = 0.3; // Smooth transitions
};
“`

### Keyboard Shortcuts
– **Ctrl+A**: Select all elements
– **Delete**: Remove selected elements
– **Ctrl+Z**: Undo last action
– **Ctrl+Y**: Redo last action
– **Space**: Fit diagram to view
– **Ctrl+0**: Reset zoom to 100%
– **+/-**: Zoom in/out
– **Arrow Keys**: Fine-tune selected element positions

—

## Background Graphics Support

The Sankey diagram plugin provides comprehensive background graphics support through multiple mechanisms:

### Background Image Support
“`cpp
// Configure background image
config.customProperties[“backgroundImage”] = “path/to/background.png”;
config.customProperties[“backgroundMode”] = “stretch”; // stretch, tile, center, fit
config.customProperties[“backgroundOpacity”] = “0.3”; // 0.0-1.0
config.customProperties[“backgroundBlendMode”] = “multiply”; // normal, multiply, overlay
“`

### Background Patterns
“`cpp
// Predefined patterns
config.customProperties[“backgroundPattern”] = “grid”; // grid, dots, lines, diagonal
config.customProperties[“patternColor”] = “#E0E0E0”;
config.customProperties[“patternSpacing”] = “20”; // Pattern spacing in pixels
config.customProperties[“patternOpacity”] = “0.1”;
“`

### Gradient Backgrounds
“`cpp
// Linear gradients
config.customProperties[“backgroundGradient”] = “linear”;
config.customProperties[“gradientStart”] = “#F0F8FF”;
config.customProperties[“gradientEnd”] = “#E6F3FF”;
config.customProperties[“gradientDirection”] = “vertical”; // horizontal, vertical, diagonal

// Radial gradients
config.customProperties[“backgroundGradient”] = “radial”;
config.customProperties[“gradientCenter”] = “0.5,0.5”; // Center point (0-1)
config.customProperties[“gradientRadius”] = “0.8”; // Radius (0-1)
“`

### Dynamic Backgrounds
“`cpp
// Animated backgrounds
config.customProperties[“backgroundAnimation”] = “parallax”;
config.customProperties[“animationSpeed”] = “0.5”;
config.customProperties[“animationDirection”] = “horizontal”;

// Interactive backgrounds
config.customProperties[“backgroundInteractive”] = “true”;
config.customProperties[“backgroundHoverEffect”] = “brighten”;
“`

—

## API Reference

### Core Classes

#### UltraCanvasSankeyDiagram
“`cpp
class UltraCanvasSankeyDiagram : public UltraCanvasDiagramElement {
public:
// Constructor
UltraCanvasSankeyDiagram(const std::string& identifier, long id,
long x, long y, long w, long h);

// Data Management
bool LoadFromFile(const std::string& filePath);
bool LoadFromJSON(const std::string& jsonData);
bool LoadFromCSV(const std::string& csvData);
bool SetData(const SankeyDiagramData& data);
const SankeyDiagramData& GetData() const;

// Configuration
void SetLayoutConfig(const SankeyLayoutConfig& config);
void SetStyleConfig(const SankeyStyleConfig& config);
void SetRenderConfig(const SankeyRenderConfig& config);

// Rendering Control
bool RenderDiagram() override;
bool RenderAsync();
void RefreshLayout();
void ApplyStyles();

// Interactive Methods
std::vector GetSelectedNodes();
std::vector GetSelectedFlows();
void SelectNode(const std::string& nodeId, bool addToSelection = false);
void SelectFlow(const std::string& flowId, bool addToSelection = false);
void ClearSelection();

// Query Methods
SankeyNode GetNodeAtPosition(Point2D position);
SankeyFlow GetFlowAtPosition(Point2D position);
std::vector GetFlowsForNode(const std::string& nodeId);
double GetTotalFlow();

// Export Methods
bool ExportToSVG(const std::string& filePath);
bool ExportToPNG(const std::string& filePath, int width = -1, int height = -1);
bool ExportToPDF(const std::string& filePath);
std::string GetSVGString();

// Animation Control
void StartFlowAnimation();
void StopFlowAnimation();
void SetAnimationSpeed(double speed);

// Event Callbacks
std::function onNodeClick;
std::function onFlowClick;
std::function onNodeHover;
std::function onFlowHover;
std::function&)> onSelectionChanged;
std::function onStateChanged;
std::function onError;
std::function onLayoutComplete;
std::function onRenderComplete;
};
“`

### Factory Functions
“`cpp
// Create Sankey diagram element
std::shared_ptr CreateSankeyDiagram(
const std::string& identifier, long id, long x, long y, long w, long h);

// Create with data
std::shared_ptr CreateSankeyDiagramWithData(
const std::string& identifier, long id, long x, long y, long w, long h,
const SankeyDiagramData& data);

// Create from file
std::shared_ptr CreateSankeyDiagramFromFile(
const std::string& identifier, long id, long x, long y, long w, long h,
const std::string& dataFilePath);
“`

—

## Usage Examples

### Basic Sankey Diagram
“`cpp
#include “UltraCanvasSankeyDiagram.h”

// Create diagram element
auto sankeyDiagram = CreateSankeyDiagram(“energyFlow”, 1, 50, 50, 800, 600);

// Prepare data
SankeyDiagramData data;

// Add nodes
data.AddNode(SankeyNode{“coal”, “Coal”, Point2D(0, 0), Size2D(80, 30)});
data.AddNode(SankeyNode{“oil”, “Oil”, Point2D(0, 0), Size2D(60, 30)});
data.AddNode(SankeyNode{“electricity”, “Electricity”, Point2D(0, 0), Size2D(100, 40)});
data.AddNode(SankeyNode{“industry”, “Industry”, Point2D(0, 0), Size2D(80, 30)});

// Add flows
data.AddFlow(SankeyFlow{“coal_elec”, “coal”, “electricity”, 60.0});
data.AddFlow(SankeyFlow{“oil_elec”, “oil”, “electricity”, 40.0});
data.AddFlow(SankeyFlow{“elec_industry”, “electricity”, “industry”, 100.0});

// Configure layout
SankeyLayoutConfig layoutConfig;
layoutConfig.algorithm = LayoutAlgorithm::Layered;
layoutConfig.nodeSpacing = 200.0;
layoutConfig.levelSpacing = 50.0;

// Configure styling
SankeyStyleConfig styleConfig;
styleConfig.colorScheme = ColorScheme::Energy;
styleConfig.enableShadows = true;
styleConfig.flowOpacity = 0.7;

// Apply configuration
sankeyDiagram->SetData(data);
sankeyDiagram->SetLayoutConfig(layoutConfig);
sankeyDiagram->SetStyleConfig(styleConfig);

// Set up callbacks
sankeyDiagram->onNodeClick = [](const std::string& nodeId) {
std::cout << "Node clicked: " << nodeId << std::endl; }; sankeyDiagram->onError = [](const std::string& error) {
std::cerr << "Sankey Error: " << error << std::endl; }; // Add to window and render window->AddElement(sankeyDiagram.get());
sankeyDiagram->RenderDiagram();
“`

### Loading from JSON Data
“`cpp
// JSON data structure
std::string jsonData = R”({
“nodes”: [
{“id”: “source1”, “label”: “Source A”, “category”: “input”},
{“id”: “source2”, “label”: “Source B”, “category”: “input”},
{“id”: “process”, “label”: “Processing”, “category”: “intermediate”},
{“id”: “output1”, “label”: “Output X”, “category”: “output”},
{“id”: “output2”, “label”: “Output Y”, “category”: “output”}
],
“flows”: [
{“source”: “source1”, “target”: “process”, “value”: 30},
{“source”: “source2”, “target”: “process”, “value”: 20},
{“source”: “process”, “target”: “output1”, “value”: 25},
{“source”: “process”, “target”: “output2”, “value”: 25}
]
})”;

// Load and configure
auto sankeyDiagram = CreateSankeyDiagram(“processFlow”, 2, 100, 100, 600, 400);
sankeyDiagram->LoadFromJSON(jsonData);

// Configure with background image
SankeyRenderConfig renderConfig;
renderConfig.backgroundImage = “factory_background.png”;
renderConfig.backgroundMode = BackgroundMode::Fit;
renderConfig.backgroundOpacity = 0.3;

sankeyDiagram->SetRenderConfig(renderConfig);
sankeyDiagram->RenderDiagram();
“`

### Advanced Interactive Configuration
“`cpp
// Create interactive diagram
auto sankeyDiagram = CreateSankeyDiagram(“interactive”, 3, 0, 0, 1000, 700);

// Configure interactions
SankeyInteractionConfig interactionConfig;
interactionConfig.enableSelection = true;
interactionConfig.selectionMode = SelectionMode::Multiple;
interactionConfig.enableHover = true;
interactionConfig.hoverStyle = HoverHighlight::Glow;

sankeyDiagram->SetInteractionConfig(interactionConfig);

// Advanced callbacks
sankeyDiagram->onNodeHover = [](const std::string& nodeId) {
// Show detailed tooltip or highlight connected flows
std::cout << "Hovering node: " << nodeId << std::endl; }; sankeyDiagram->onSelectionChanged = [](const std::vector& selectedIds) {
std::cout << "Selection: "; for (const auto& id : selectedIds) { std::cout << id << " "; } std::cout << std::endl; }; sankeyDiagram->onLayoutComplete = []() {
std::cout << "Layout calculation finished" << std::endl; }; ``` --- ## Advanced Configuration ### Custom Color Schemes ```cpp // Define custom color palette std::vector customPalette = {
Color(255, 99, 132), // Red
Color(54, 162, 235), // Blue
Color(255, 205, 86), // Yellow
Color(75, 192, 192), // Teal
Color(153, 102, 255), // Purple
Color(255, 159, 64) // Orange
};

SankeyStyleConfig styleConfig;
styleConfig.colorScheme = ColorScheme::Custom;
styleConfig.customColors = customPalette;
“`

### Performance Tuning
“`cpp
// High-performance configuration for large datasets
SankeyRenderConfig perfConfig = SankeyRenderConfig::Performance();
perfConfig.enableLevelOfDetail = true;
perfConfig.detailThreshold = 0.3;
perfConfig.maxRenderThreads = std::thread::hardware_concurrency();
perfConfig.enableGPUAcceleration = true;

// Cache settings
perfConfig.enableCaching = true;
perfConfig.cacheDirectory = “cache/sankey”;
perfConfig.maxCacheSize = 500; // MB
“`

### Export Configuration
“`cpp
// High-quality export settings
SankeyRenderConfig exportConfig = SankeyRenderConfig::HighQuality();
exportConfig.dpi = 300;
exportConfig.antiAliasingLevel = AntiAliasing::Ultra;
exportConfig.width = 3000; // High resolution
exportConfig.height = 2000;

// Export with specific settings
sankeyDiagram->SetRenderConfig(exportConfig);
sankeyDiagram->ExportToPNG(“high_quality_diagram.png”, 3000, 2000);
“`

—

## Integration Guide

### Window Integration
“`cpp
// Add to UltraCanvas window
auto window = CreateWindow(“Sankey Demo”, 100, 100, 1200, 800);
auto sankeyDiagram = CreateSankeyDiagram(“main”, 1, 10, 10, 1180, 780);

// Configure window properties
sankeyDiagram->SetBackgroundColor(Colors::White);
sankeyDiagram->SetBorder(true, Colors::Gray, 1);

window->AddElement(sankeyDiagram.get());
window->Show();
“`

### Plugin Registration
“`cpp
// Register Sankey diagram renderer
UltraCanvasDiagramRendererRegistry::RegisterRenderer(
std::make_shared()
);

// Verify registration
auto renderers = UltraCanvasDiagramRendererRegistry::GetRenderers();
std::cout << "Registered renderers: " << renderers.size() << std::endl; ``` ### Thread Safety ```cpp // Safe multi-threaded access std::mutex sankeyMutex; // Update data from background thread std::thread dataThread([&]() { SankeyDiagramData newData = LoadDataFromDatabase(); std::lock_guard lock(sankeyMutex);
sankeyDiagram->SetData(newData);
sankeyDiagram->RenderAsync();
});
“`

—

## Performance Optimization

### Large Dataset Handling
– **Node Limit**: Efficiently handles up to 10,000 nodes
– **Flow Limit**: Supports up to 50,000 flows with optimization
– **Memory Management**: Automatic cleanup of unused resources
– **Streaming Data**: Incremental loading for massive datasets

### Rendering Optimization
– **Level of Detail**: Automatic simplification at low zoom levels
– **Culling**: Skip rendering of off-screen elements
– **Caching**: Smart caching of layout calculations
– **GPU Acceleration**: Hardware-accelerated rendering where available

### Best Practices
“`cpp
// Optimize for large datasets
SankeyLayoutConfig optimizedLayout;
optimizedLayout.maxIterations = 500; // Reduce iterations
optimizedLayout.convergenceThreshold = 0.5; // Looser convergence

SankeyRenderConfig optimizedRender;
optimizedRender.enableLevelOfDetail = true;
optimizedRender.detailThreshold = 0.2; // Aggressive LOD
optimizedRender.maxRenderThreads = 8; // Parallel processing
“`

—

## Troubleshooting

### Common Issues

#### Layout Problems
**Issue**: Nodes overlapping or poor positioning
**Solution**:
“`cpp
layoutConfig.allowOverlap = false;
layoutConfig.nodeSpacing = 100.0; // Increase spacing
layoutConfig.maxIterations = 2000; // More layout iterations
“`

#### Performance Issues
**Issue**: Slow rendering with large datasets
**Solution**:
“`cpp
renderConfig.enableLevelOfDetail = true;
renderConfig.enableGPUAcceleration = true;
renderConfig.maxRenderThreads = std::thread::hardware_concurrency();
“`

#### Visual Artifacts
**Issue**: Jagged lines or poor quality
**Solution**:
“`cpp
renderConfig.antiAliasingLevel = AntiAliasing::Ultra;
renderConfig.dpi = 300; // Higher DPI
renderConfig.useSubPixelRendering = true;
“`

### Debug Configuration
“`cpp
// Enable debug mode for troubleshooting
DiagramRenderConfig debugConfig;
debugConfig.customProperties[“debug”] = “true”;
debugConfig.customProperties[“showBounds”] = “true”;
debugConfig.customProperties[“showFlow IDs”] = “true”;
debugConfig.customProperties[“logLevel”] = “verbose”;
“`

### Error Handling
“`cpp
// Comprehensive error handling
sankeyDiagram->onError = [](const std::string& error) {
std::cerr << "Sankey Error: " << error << std::endl; // Log to file std::ofstream logFile("sankey_errors.log", std::ios::app); logFile << std::time(nullptr) << ": " << error << std::endl; }; // Validate data before rendering std::vector validationErrors;
if (!data.ValidateData(validationErrors)) {
for (const auto& error : validationErrors) {
std::cerr << "Data Error: " << error << std::endl; } } ``` --- ## Conclusion The UltraCanvas Sankey Diagram Plugin provides a comprehensive, high-performance solution for creating interactive flow diagrams. With extensive customization options, background graphics support, and robust performance optimization, it's suitable for both simple visualizations and complex enterprise applications. For additional support and examples, refer to the UltraCanvas documentation and sample applications in the framework repository.