uneca/plotly-chart-editor
Reactive Plotly.js chart builder for Laravel via Livewire. Sidebar-driven editor to configure traces and layout, multi-language UI (EN/FR/PT/ES), multiple sync modes and persistence options. Requires Plotly.js 3.x (peer dep), Alpine, PHP 8.4+.
dataSources (raw data) and traces (Plotly config) is a clean architectural pattern.config/plotly-chart-editor.php, allowing customization without modifying core code. The ValidChartConfig rule ensures API consistency.dataSources prop requires careful design (immutable arrays of equal length), but this enforces data integrity. The getCompiledTraces() utility simplifies read-only rendering.hybrid mode (auto + manual save) is ideal for most use cases, balancing UX and backend load.ValidChartConfig rule is a safeguard, but edge cases (e.g., malformed meta.columnNames) may still slip through.dataSources be managed? Will they be static (e.g., hardcoded) or dynamically fetched (e.g., API calls)?auto, manual, hybrid) best fits the use case? Auto-sync may overwhelm the backend for frequent edits.sync-failed events, but UI feedback must be implemented.chart-synced) integrates seamlessly with Laravel’s backend.chartBuilder.purge vs. react).--plotly-editor-* CSS variables.composer require uneca/plotly-chart-editor
Add Blade directives to resources/views/layouts/app.blade.php:
@plotlyChartEditorStyles
@plotlyChartEditorScripts
@livewireStyles
dataSources in your controller (e.g., $rawDataset).<livewire:plotly-editor :data-sources="$rawDataset" />
Schema::create('charts', function (Blueprint $table) {
$table->id();
$table->json('traces');
$table->json('layout');
$table->timestamps();
});
@livewireScripts placement.dataSources in your model/controller.<livewire:plotly-editor> in your view.auto, manual, hybrid) with real data.php artisan vendor:publish --tag="plotly-chart-editor-config"
Livewire::test() for component testing and Alpine.store('chartBuilder') for runtime inspection. The sync-failed event helps diagnose sync issues.meta.columnNames).area vs. scatter).hybrid).dataSources → traces → layout).auto vs. manual).sync-failed event).auto/hybrid mode) may flood the backend. Debounce thresholds (default: 500ms) can be adjusted.traces, layout) work well for small-to-medium charts. For large-scale apps, consider:
jsonb (PostgreSQL) or serialize().getCompiledTraces()) if charts are static.dataSources if they’re expensive to fetch.| Scenario | Impact | Mitigation |
|---|---|---|
| Plotly.js Missing | Editor renders but chart fails to display. | Add a fallback UI with a warning. |
Invalid dataSources |
Column binding errors; chart renders with NaN. |
Validate dataSources in the controller. |
| Sync Failures | Unsaved changes lost. | Implement local state persistence (e.g., sessionStorage) or a "dirty" flag. |
| Backend Overload | Auto-sync floods API. | Use manual mode or increase debounce time. |
| CSS Conflicts | Styling breaks due to Tailwind/other CSS. | Scope package classes (e.g., plotly-editor__*). |
Alpine.store('chartBuilder') works for debugging.auto vs. manual to avoid unexpected saves.meta.columnNames match dataSourcesHow can I help you explore Laravel packages today?