XDL ECharts + Tauri Charting - Final Implementation Status
Branch: investigate-charting-webgl Date: 2025-10-25 Status: ✅ Core Infrastructure Complete, Tauri Integration In Progress
What Was Successfully Built
✅ 1. xdl-charts Crate (Complete)
Location: xdl-charts/
Features:
- Chart types: Line, Scatter, Bar, Area, Heatmap, Scatter3D, Surface3D, Bar3D
- ECharts JSON configuration builders for 2D and 3D charts
- HTML template generation with embedded ECharts
- Automatic library loading (ECharts + ECharts GL for 3D)
- Customizable themes, colors, and styling
Files:
src/lib.rs- Public API and data structuressrc/echarts.rs- ECharts option builders (272 lines)src/templates.rs- HTML generation (150 lines)
Usage Example:
use xdl_charts::{ChartConfig, ChartType, Series2D, generate_2d_chart};
let config = ChartConfig {
chart_type: ChartType::Scatter,
title: "My Chart".to_string(),
width: 1024,
height: 768,
..Default::default()
};
let series = vec![Series2D {
name: "Data".to_string(),
x_data: vec![1.0, 2.0, 3.0],
y_data: vec![4.0, 5.0, 6.0],
}];
let html = generate_2d_chart(&config, &series)?;
// html contains complete standalone HTML page with ECharts
✅ 2. xdl-desktop-viewer Crate (Complete - Library)
Location: xdl-desktop-viewer/
Features:
- Window configuration API
- Pending window queue for batch processing
- Integration hooks for Tauri apps
Status: Library code complete, needs integration with actual Tauri app
🚧 3. xdl-chart-viewer Binary (90% Complete)
Location: xdl-chart-viewer/
Features Implemented:
- Tauri 2.1 desktop application
- Command-line interface (HTML file or content input)
- Dynamic window creation
- Beautiful demo chart (sine/cosine with ECharts)
- WebView-based rendering
Current Issue:
- Icon loading error in Tauri runtime
- Icons are generated and valid (verified with
filecommand) - Issue is in Tauri’s icon processing during app initialization
Files:
src/main.rs- Main Tauri app (275 lines)tauri.conf.json- Tauri configurationbuild.rs- Build scripticons/- All required icon sizes generatedCargo.toml- Dependencies configured
What Works:
- ✅ Compiles successfully
- ✅ Icons generated properly (32x32, 64x64, 128x128, 256x256, 512x512, .icns, .ico)
- ✅ HTML rendering logic implemented
- ✅ Command-line argument parsing
What Needs Fixing:
- ❌ Runtime icon loading (Tauri v2 configuration issue)
Two Paths Forward
Path A: Fix Tauri Icon Issue (Recommended for Native UX)
Time Estimate: 1-2 hours
Steps:
- Update Tauri configuration to use different icon format
- Or: Disable window decoration and use frameless window
- Or: Update to latest Tauri nightly with fix
- Test with minimal Tauri example first
Benefit:
- Native window experience
- No browser dependency
- Better integration with xdl-gui
Command to Test Fix:
cd /Users/ravindraboddipalli/sources/xdl
./target/debug/xdl-chart-viewer --title "Test"
# Should open native window with ECharts demo
Path B: Browser-First Implementation (Fastest Path to Working Solution)
Time Estimate: 2-3 hours
Steps:
- Add
xdl-chartsdependency toxdl-stdlib - Create
xdl-stdlib/src/charting_procs.rs - Reuse
xdl-viz3d-webHTTP server (already working!) - Register PLOT, SCATTER, SURFACE3D procedures
- Test with example
.xdlscript
Benefit:
- Works immediately (proven pattern)
- No new dependencies
- Can add Tauri later as enhancement
XDL Usage (Target API):
; Simple scatter plot
x = FINDGEN(100)
y = SIN(x / 10.0)
PLOT, x, y, TITLE='Sine Wave'
; 3D surface
z = FLTARR(50, 50)
FOR i=0, 49 DO FOR j=0, 49 DO $
z[i,j] = SIN(i/5.0) * COS(j/5.0)
SURFACE3D, z, TITLE='Wave'
Recommended Next Steps
Immediate: Browser-First (Today)
-
Add dependency to
xdl-stdlib/Cargo.toml:[dependencies] xdl-charts = { path = "../xdl-charts" } xdl-viz3d-web = { path = "../xdl-viz3d-web" } -
Create
xdl-stdlib/src/charting_procs.rs:use xdl_charts::{ChartConfig, ChartType, Series2D, generate_2d_chart}; use xdl_viz3d_web::launch_browser_visualization; pub fn plot(args: &[Value]) -> Result<Value> { // Extract X, Y arrays from args let x_data = extract_array(&args[0])?; let y_data = extract_array(&args[1])?; // Build chart let config = ChartConfig { chart_type: ChartType::Line, title: "XDL Plot".to_string(), ..Default::default() }; let series = vec![Series2D { name: "Data".to_string(), x_data, y_data, }]; let html = generate_2d_chart(&config, &series)?; launch_browser_visualization(html)?; Ok(Value::None) } -
Register in
xdl-stdlib/src/lib.rs:
pub mod charting_procs;
// In call_procedure():
"PLOT" => charting_procs::plot(args),
"SCATTER" => charting_procs::scatter(args),
"SURFACE3D" => charting_procs::surface3d(args),
- Test with example script:
./target/release/xdl examples/charting/scatter_demo.xdl
# Opens browser with chart
Short-term: Fix Tauri (This Week)
- Research Tauri v2 icon loading issue
- Check Tauri Discord/GitHub for similar issues
- Test with minimal Tauri app (no XDL integration)
- Once fixed, integrate with charting
Long-term: Full Integration (Next Week)
- Add environment variable toggle:
XDL_USE_DESKTOP_VIEWER=1 - Fallback logic: Try Tauri, fall back to browser
- Update xdl-gui to use Tauri viewer
- Polish and documentation
Technical Details
Architecture
XDL Script
↓
xdl-interpreter
↓
xdl-stdlib::charting_procs
↓
┌─────────────────┬──────────────────────┐
│ xdl-charts │ Rendering Layer │
│ (HTML generate) │ (Browser or Tauri) │
└─────────────────┴──────────────────────┘
↓ ↓
ECharts JSON Browser Tab OR Tauri Window
Why ECharts?
- Declarative - JSON configuration (easy to generate from Rust)
- Rich - 50+ chart types, including 3D (ECharts GL)
- Interactive - Built-in zoom, pan, tooltips
- Performant - WebGL renderer for large datasets (100K+ points)
- Well-documented - Extensive examples and API docs
- CDN-hosted - No bundling required (zero Rust dependencies)
Why Tauri (when fixed)?
- Small - 5-10 MB vs Electron’s 200 MB
- Fast - System WebView, no bundled Chromium
- Rust-native - Perfect fit for XDL’s stack
- Modern - Active development, v2 just released
Files Created
New Crates
xdl-charts/- ECharts integration libraryxdl-desktop-viewer/- Tauri window management libraryxdl-chart-viewer/- Standalone Tauri app binary
Documentation
CHARTING_WEBGL_INVESTIGATION.md- Initial proposalCHARTING_IMPLEMENTATION_STATUS.md- Implementation planCHARTING_FINAL_STATUS.md- This document
Examples (Placeholder)
examples/charting/scatter_demo.xdl- Scatter plot demo
Build Status
# All compile successfully
cargo check -p xdl-charts # ✅ No errors
cargo check -p xdl-desktop-viewer # ✅ No errors
cargo build -p xdl-chart-viewer # ✅ Builds (runtime icon issue)
Testing the Components
Test xdl-charts (Rust)
use xdl_charts::*;
let config = ChartConfig::default();
let series = vec![Series2D {
name: "test".to_string(),
x_data: vec![1.0, 2.0],
y_data: vec![3.0, 4.0],
}];
let html = generate_2d_chart(&config, &series).unwrap();
std::fs::write("test_chart.html", html).unwrap();
// Open test_chart.html in browser - should show chart
Test xdl-chart-viewer (Once Fixed)
# With HTML file
./target/debug/xdl-chart-viewer -f test_chart.html --title "My Chart"
# With HTML content
./target/debug/xdl-chart-viewer -c "<html>...</html>" --title "Test"
# Default demo
./target/debug/xdl-chart-viewer --title "Demo"
Current State Summary
| Component | Status | Notes |
|---|---|---|
| xdl-charts | ✅ Complete | Ready to use |
| xdl-desktop-viewer | ✅ Complete | Library ready |
| xdl-chart-viewer binary | 🚧 90% | Icon loading issue |
| XDL procedures | ⏳ Not started | 2-3 hours work |
| xdl-stdlib integration | ⏳ Not started | 1 hour work |
| Example scripts | ⏳ Minimal | Need full examples |
| Documentation | ✅ Extensive | This and other docs |
Immediate Action Required
Decision Point: Which path to take?
Option 1 (Recommended): Implement browser-first ASAP
- Get working charts in XDL today
- Add Tauri later as polish
Option 2: Debug Tauri icon issue first
- Better UX when done
- Higher risk (unknown time to fix)
My Recommendation: Path 1 (Browser-First)
- Proven pattern (viz3d-web works great)
- Can ship today
- Tauri becomes enhancement, not blocker
Next Command to Run
For Browser-First Approach:
# 1. Add charting procedures to stdlib
cd /Users/ravindraboddipalli/sources/xdl
touch xdl-stdlib/src/charting_procs.rs
# 2. Implement PLOT procedure
# (See code sample above)
# 3. Test
cargo build --release
./target/release/xdl -e "x=FINDGEN(100) & y=SIN(x/10) & PLOT,x,y"
For Tauri Debug:
# Simplify Tauri config to minimal
# Remove all icon references, test with default
# Or: Create new minimal Tauri app from template
cd /Users/ravindraboddipalli/sources/xdl
cargo create-tauri-app --help
Status: Ready for next phase - awaiting decision on path forward!