A Chart.js integration plugin for Editor.js that allows you to create charts right in the editor.
- 6 Chart Types: Bar, Line, Pie, Doughnut, Radar, and Polar Area charts
- Full Editability: Edit labels, data values, titles, and colors in real-time
- Color Picker: Choose from 12 preset colors for your charts
- Multiple Datasets: Support for multiple data sets (in non-segmented charts)
npm install editorjs-chartjs chart.jsimport EditorJS from '@editorjs/editorjs';
import ChartTool from 'editorjs-chartjs';
const editor = new EditorJS({
holder: 'editorjs',
tools: {
chart: {
class: ChartTool,
},
},
});const editor = new EditorJS({
holder: 'editorjs',
tools: {
chart: ChartTool,
},
data: {
blocks: [
{
type: 'chart',
data: {
type: 'bar',
title: 'Monthly Revenue',
labels: ['Jan', 'Feb', 'Mar', 'Apr'],
datasets: [
{
label: 'Sales',
data: [12000, 19000, 15000, 25000],
backgroundColor: '#4A90E2',
},
],
},
},
],
},
});npm installnpm run devThis will start a Vite dev server at http://localhost:5173 with a live demo of the chart tool.
npm run buildThe built files will be in the dist/ directory.
The plugin saves data in the following format:
{
type: 'bar', // Chart type
title: 'Chart Title', // Optional chart title
labels: ['A', 'B'], // X-axis labels
datasets: [
{
label: 'Dataset 1', // Dataset name
data: [10, 20], // Values
backgroundColor: '#4A90E2' // Color
}
]
}The plugin comes with 12 preset colors:
- Blue (#4A90E2)
- Green (#50C878)
- Red (#FF6B6B)
- Yellow (#FFD93D)
- Purple (#A29BFE)
- Pink (#FD79A8)
- Orange (#FDCB6E)
- Teal (#00B894)
- Indigo (#6C5CE7)
- Coral (#E17055)
- Sky Blue (#74B9FF)
- Mint (#55EFC4)
You can customize the appearance by overriding the CSS classes:
.chart-tool {
/* Main wrapper */
}
.chart-tool__canvas-wrapper {
/* Chart canvas container */
}
.chart-tool__settings {
/* Settings panel */
}Built with:

