|
| 1 | +# @dschz/solid-plotly |
| 2 | + |
| 3 | +## 0.1.0 |
| 4 | + |
| 5 | +### 🎉 Initial Release |
| 6 | + |
| 7 | +Welcome to `@dschz/solid-plotly` - a modern, type-safe SolidJS wrapper for Plotly.js with fine-grained reactivity and comprehensive event support! |
| 8 | + |
| 9 | +### ✨ Major Features |
| 10 | + |
| 11 | +#### 🏭 **Factory Pattern Architecture** |
| 12 | + |
| 13 | +- **Plotly-agnostic design** - Bring your own Plotly.js bundle for optimal bundle size |
| 14 | +- **Flexible distribution support** - Works with `plotly.js-dist-min`, `plotly.js-basic-dist`, `plotly.js-dist`, or custom builds |
| 15 | +- **Tree-shakable** - Only includes the Plotly.js features you actually use |
| 16 | +- **Zero bundled dependencies** - No Plotly.js version lock-in |
| 17 | + |
| 18 | +#### ⚡ **SolidJS Integration** |
| 19 | + |
| 20 | +- **Fine-grained reactivity** - Leverages SolidJS's reactive primitives for optimal performance |
| 21 | +- **Efficient updates** - Only re-renders when data actually changes |
| 22 | +- **Automatic lifecycle management** - Handles component mounting, updating, and cleanup |
| 23 | +- **Signal-friendly** - Works seamlessly with SolidJS signals and stores |
| 24 | + |
| 25 | +#### 📱 **Responsive by Default** |
| 26 | + |
| 27 | +- **Automatic resizing** - Built-in ResizeObserver integration for responsive charts |
| 28 | +- **Container-aware** - Automatically adapts to parent container size changes |
| 29 | +- **Performance optimized** - Efficient resize handling with proper cleanup |
| 30 | +- **Configurable** - Can be disabled via `useResize={false}` prop |
| 31 | + |
| 32 | +#### 🎯 **Complete TypeScript Support** |
| 33 | + |
| 34 | +- **Full type safety** - Comprehensive TypeScript definitions for all Plotly.js types |
| 35 | +- **Utility types** - Exported `PlotlyData`, `PlotlyLayout`, `PlotlyConfig`, and more |
| 36 | +- **JSDoc documentation** - Detailed inline documentation for all props and methods |
| 37 | +- **IntelliSense support** - Rich autocompletion and type checking in IDEs |
| 38 | + |
| 39 | +### 🎪 **Event System** |
| 40 | + |
| 41 | +#### **30+ Event Handlers** |
| 42 | + |
| 43 | +Complete support for all official Plotly.js events: |
| 44 | + |
| 45 | +**Mouse & Interaction Events:** |
| 46 | + |
| 47 | +- `onClick`, `onDoubleClick`, `onHover`, `onUnhover` |
| 48 | + |
| 49 | +**Selection Events:** |
| 50 | + |
| 51 | +- `onSelected`, `onSelecting`, `onDeselect` |
| 52 | + |
| 53 | +**Layout Events:** |
| 54 | + |
| 55 | +- `onRelayout`, `onRelayouting`, `onRestyle` |
| 56 | + |
| 57 | +**Legend Events:** |
| 58 | + |
| 59 | +- `onLegendClick`, `onLegendDoubleClick` |
| 60 | + |
| 61 | +**UI Element Events:** |
| 62 | + |
| 63 | +- `onClickAnnotation`, `onSliderChange`, `onSliderStart`, `onSliderEnd` |
| 64 | + |
| 65 | +**Plot Lifecycle Events:** |
| 66 | + |
| 67 | +- `onAfterPlot`, `onBeforePlot`, `onRedraw`, `onAutoSize` |
| 68 | + |
| 69 | +**Animation Events:** |
| 70 | + |
| 71 | +- `onAnimated`, `onAnimatingFrame`, `onAnimationInterrupted`, `onTransitioning`, `onTransitionInterrupted` |
| 72 | + |
| 73 | +**Export Events:** |
| 74 | + |
| 75 | +- `onAfterExport`, `onBeforeExport` |
| 76 | + |
| 77 | +**Framework Events:** |
| 78 | + |
| 79 | +- `onFramework`, `onSunburstClick`, `onEvent` |
| 80 | + |
| 81 | +#### **Lifecycle Callbacks** |
| 82 | + |
| 83 | +- `onInitialized` - Fired when plot is first created |
| 84 | +- `onUpdate` - Fired when plot data/layout updates |
| 85 | +- `onPurge` - Fired when plot is destroyed |
| 86 | +- `onResize` - Fired when plot is resized |
| 87 | +- `onError` - Fired when errors occur during plot operations |
| 88 | + |
| 89 | +### 🛠 **Component API** |
| 90 | + |
| 91 | +#### **Core Props** |
| 92 | + |
| 93 | +- `data: PlotlyData[]` - Array of data traces (required) |
| 94 | +- `layout?: PlotlyLayout` - Layout configuration for axes, title, margins, etc. |
| 95 | +- `config?: PlotlyConfig` - Plotly configuration options |
| 96 | +- `frames?: PlotlyFrame[]` - Animation frames for animated plots |
| 97 | + |
| 98 | +#### **Customization Props** |
| 99 | + |
| 100 | +- `id?: string` - Container element ID (default: "solid-plotly") |
| 101 | +- `class?: string` - CSS class names for styling |
| 102 | +- `style?: JSX.CSSProperties` - Inline styles |
| 103 | +- `ref?: (el: HTMLDivElement) => void` - Access to underlying DOM element |
| 104 | + |
| 105 | +#### **Behavior Props** |
| 106 | + |
| 107 | +- `useResize?: boolean` - Enable/disable automatic resizing (default: true) |
| 108 | + |
| 109 | +### 🔧 **Developer Experience** |
| 110 | + |
| 111 | +#### **Comprehensive Documentation** |
| 112 | + |
| 113 | +- **Detailed README** - Complete API reference with examples |
| 114 | +- **TypeScript examples** - Real-world usage patterns |
| 115 | +- **Multiple chart types** - Examples for scatter, bar, line, pie, and more |
| 116 | +- **Animation examples** - Frame-based and real-time data updates |
| 117 | +- **Event handling examples** - Interactive chart implementations |
| 118 | + |
| 119 | +#### **Example Patterns** |
| 120 | + |
| 121 | +- **Reactive data updates** - Dynamic chart updates with SolidJS signals |
| 122 | +- **Event handling** - Interactive charts with click, hover, and selection |
| 123 | +- **Responsive layouts** - Auto-resizing charts that adapt to containers |
| 124 | +- **Animation** - Smooth transitions and real-time data streaming |
| 125 | +- **Error handling** - Robust error management and recovery |
| 126 | + |
| 127 | +### ✅ **Quality Assurance** |
| 128 | + |
| 129 | +#### **Comprehensive Testing** |
| 130 | + |
| 131 | +- **28 test cases** across 2 test files |
| 132 | +- **100% code coverage** - Statements, branches, functions, and lines |
| 133 | +- **Integration tests** - End-to-end component behavior testing |
| 134 | +- **Unit tests** - Individual utility function testing |
| 135 | +- **Mock-based testing** - Isolated component testing without Plotly.js dependency |
| 136 | + |
| 137 | +#### **Test Coverage Areas** |
| 138 | + |
| 139 | +- Component lifecycle (mount, update, unmount) |
| 140 | +- Event attachment and removal |
| 141 | +- Reactive data updates |
| 142 | +- Error handling and recovery |
| 143 | +- Resize observer integration |
| 144 | +- Figure data extraction |
| 145 | +- Edge cases and error conditions |
| 146 | + |
| 147 | +#### **Code Quality** |
| 148 | + |
| 149 | +- **TypeScript strict mode** - Maximum type safety |
| 150 | +- **ESLint configuration** - Consistent code style and best practices |
| 151 | +- **Prettier formatting** - Automated code formatting |
| 152 | +- **Build validation** - Successful compilation and bundling |
| 153 | + |
| 154 | +### 🎛 **Supported Plotly.js Distributions** |
| 155 | + |
| 156 | +#### **Recommended for Web Apps** |
| 157 | + |
| 158 | +- `plotly.js-dist-min` (~4.3MB minified, ~1.3MB minified+gzipped) - Most chart types with full features |
| 159 | + |
| 160 | +#### **Other Supported Distributions** |
| 161 | + |
| 162 | +- `plotly.js-basic-dist` (~2.7MB unpacked, ~333KB minified+gzipped) - Basic chart types (bar, pie, scatter) |
| 163 | +- `plotly.js-dist` (~10.8MB unpacked, ~1.3MB minified+gzipped) - All chart types and features |
| 164 | +- `plotly.js` - Custom builds with cherry-picked modules |
| 165 | + |
| 166 | +### 📦 **Package Information** |
| 167 | + |
| 168 | +#### **Bundle Characteristics** |
| 169 | + |
| 170 | +- **Zero runtime dependencies** - Only peer dependency on solid-js |
| 171 | +- **Small bundle size** - Core library is lightweight and tree-shakable |
| 172 | +- **ESM and CJS support** - Works in modern and legacy environments |
| 173 | +- **TypeScript declarations** - Complete .d.ts files for type checking |
| 174 | + |
| 175 | +#### **Peer Dependencies** |
| 176 | + |
| 177 | +- `solid-js >= 1.6.0` - Compatible with all modern SolidJS versions |
| 178 | + |
| 179 | +#### **Runtime Dependencies** |
| 180 | + |
| 181 | +- `@dschz/try-catch ^1.1.2` - Utility for safe async operations |
| 182 | + |
| 183 | +### 🚀 **Getting Started** |
| 184 | + |
| 185 | +```bash |
| 186 | +# Install the library |
| 187 | +npm install @dschz/solid-plotly |
| 188 | + |
| 189 | +# Choose your Plotly.js distribution |
| 190 | +npm install plotly.js-dist-min # Recommended for most web apps |
| 191 | +``` |
| 192 | + |
| 193 | +```tsx |
| 194 | +import Plotly from "plotly.js-dist-min"; |
| 195 | +import { createPlotComponent } from "@dschz/solid-plotly"; |
| 196 | + |
| 197 | +// Create your Plot component |
| 198 | +const Plot = createPlotComponent(Plotly); |
| 199 | + |
| 200 | +// Use in your app |
| 201 | +function MyChart() { |
| 202 | + return ( |
| 203 | + <Plot |
| 204 | + data={[{ x: [1, 2, 3], y: [1, 4, 2], type: "scatter" }]} |
| 205 | + layout={{ title: "My First Chart" }} |
| 206 | + onClick={(event) => console.log("Clicked:", event.points)} |
| 207 | + /> |
| 208 | + ); |
| 209 | +} |
| 210 | +``` |
| 211 | + |
| 212 | +### 📋 **Migration Notes** |
| 213 | + |
| 214 | +This is the initial release, so no migration is needed. Future releases will include migration guides as needed. |
| 215 | + |
| 216 | +### 🙏 **Acknowledgments** |
| 217 | + |
| 218 | +Special thanks to: |
| 219 | + |
| 220 | +- The [SolidJS](https://solidjs.com) team for the amazing reactive framework |
| 221 | +- The [Plotly.js](https://plotly.com/javascript/) team for the powerful charting library |
| 222 | +- The React Plotly.js community for inspiration on API design |
| 223 | + |
| 224 | +--- |
| 225 | + |
| 226 | +**Full Changelog**: https://github.com/dsnchz/solid-plotly/commits/v0.1.0 |
0 commit comments