@pmsite/chronograph
v0.3.0
Published
Reactive state management and scheduling engine for Gantt charts - WASM powered
Downloads
285
Maintainers
Readme
@pmsite/chronograph
A reactive state management and scheduling engine for Gantt charts, powered by Rust and WebAssembly.
Features
- Reactive Computation Engine: Variables, computed identifiers, automatic dependency tracking
- Undo/Redo: Built-in transaction history with configurable depth
- CPM Scheduling: Critical Path Method with forward/backward pass
- Calendar Support: Working days, hours, holidays, and exceptions
- Resource Shifts: Define shift patterns (morning, evening, custom) for resources
- Resource Leveling: Automatic conflict resolution with multiple strategies
- Custom Fields: User-defined fields with type validation for tasks, resources, and projects
- Project Save/Load: Export and import complete project state as JSON
- High Performance: Rust-compiled WASM for near-native speed
Installation
npm install @pmsite/chronographQuick Start
Reactive State Management
import init, { ChronoGraph, ChronoGraphConfig } from '@pmsite/chronograph';
await init();
const config = new ChronoGraphConfig();
config.historyLimit = 50;
const graph = new ChronoGraph(config);
// Create reactive variables
const x = graph.variableNamed('x', 10);
const y = graph.variableNamed('y', 20);
// Create computed value
const sum = graph.identifierNamed('sum', () => {
return graph.readVariable(x) + graph.readVariable(y);
});
console.log(graph.readIdentifier(sum)); // 30
graph.writeVariable(x, 15);
console.log(graph.readIdentifier(sum)); // 35
// Undo/Redo
graph.undo();
console.log(graph.readIdentifier(sum)); // 30Project Scheduling
import init, { WasmSchedulingEngine } from '@pmsite/chronograph';
await init();
const engine = new WasmSchedulingEngine();
engine.setProjectStart(Date.now());
// Add calendar with holidays
engine.addCalendar(1, 'Work Calendar');
engine.addCalendarException(1, {
date: 1703462400000,
is_working: false,
name: 'Christmas'
});
engine.setProjectCalendar(1);
// Add tasks
engine.addTask({ id: 1, name: 'Design', duration: 432000000 });
engine.addTask({ id: 2, name: 'Development', duration: 864000000 });
// Add dependency
engine.addDependency({
id: 1,
predecessor_id: 1,
successor_id: 2,
dependency_type: 'FS'
});
// Calculate CPM (respects calendar)
engine.calculateCpmWithCalendar();
// Get results
const criticalPath = engine.getCriticalPath();
const stats = engine.getProjectStats();Save and Load Projects
// Export project to JSON
const projectData = engine.exportProject();
localStorage.setItem('myProject', JSON.stringify(projectData));
// Import project from JSON
const saved = JSON.parse(localStorage.getItem('myProject'));
engine.importProject(saved);
engine.calculateCpmWithCalendar(); // Recalculate CPM after load
// Clear all project data
engine.clearProject();Resource Shifts
Define shift patterns for resources to control their working hours:
// Define shifts
const morningShift = engine.addShift({
id: 1,
name: 'Morning Shift',
intervals: [{ start_hour: 6, start_min: 0, end_hour: 14, end_min: 0 }]
});
const eveningShift = engine.addShift({
id: 2,
name: 'Evening Shift',
intervals: [{ start_hour: 14, start_min: 0, end_hour: 22, end_min: 0 }]
});
// Add resource
engine.addResource({ id: 1, name: 'Worker', max_units: 100 });
// Assign shift pattern: Mon-Wed morning, Thu-Fri evening, weekends use calendar
engine.setResourceShiftPattern(1, [
morningShift, // Monday
morningShift, // Tuesday
morningShift, // Wednesday
eveningShift, // Thursday
eveningShift, // Friday
null, // Saturday (use calendar default)
null // Sunday (use calendar default)
]);API Reference
See chronograph_api.md for complete API documentation.
Building from Source
# Install wasm-pack
cargo install wasm-pack
# Build WASM package
npm run build
# Run tests
npm testLicense
Proprietary - All rights reserved
