Documentation Index
Fetch the complete documentation index at: https://docs.doman.id/llms.txt
Use this file to discover all available pages before exploring further.
Extending the System: Creating a Custom EChartBlock.vue Widget
This guide demonstrates how to add a new widget based on a different charting library (Apache ECharts) while adhering to our established data/params API. This is useful when you need chart types not available in ApexCharts, such as Sankey diagrams, graph visualizations, or advanced 3D plots.
The process involves four key steps:
- Install the new libraries.
- Create the Vue component, translating our unified API to the ECharts format.
- Register the new component globally.
- Use the new component in your dashboard.
Step 1: Install ECharts Dependencies
First, add Apache ECharts and its official Vue 2 wrapper (vue-echarts) to your project.
vue-echarts@5. NPM should resolve this correctly.)
Step 2: Create the EChartBlock.vue Component
This is the core of the integration. We will create a new Vue component that acts as an adapter, translating our generic params object into the specific, and often more complex, configuration object that ECharts requires.
File: resources/js/components/EChartBlock.vue
Step 3: Register the New Component Globally
For the new component to be recognized, you must register it in your main JavaScript file alongside the others. File:resources/js/app.js
Step 4: Use the EChartBlock in Your Dashboard
You can now use <e-chart-block> just like any other widget. Let’s add it to our “Standard Live Dashboard” (MyReportPage.vue) to show how it fits in.
Update the Laravel Controller
First, add some data and params specifically for an ECharts pie chart in your controller. File:app/Http/Controllers/ReportController.php
Update the Vue Page Component
Now, simply add the<e-chart-block> tag to your layout.
File: resources/js/components/MyReportPage.vue
Key Takeaways
- The Power of the Unified API: Because we stuck to the
dataandparamsprops, adding a completely new widget from a different library required zero changes to theDashboardLayoutor the page’s data flow logic. - The Adapter Pattern: The new
EChartBlock.vuecomponent acts as an Adapter. It translates our simple, standardized API into the complex, specific API required by ECharts. - Infinite Extensibility: You can now follow this exact pattern to create
<GoogleChartBlock>,<DataTableBlock>,<LeafletMapBlock>, or any other custom widget you can imagine. The core architecture remains clean and stable.

