grapesjs-chartjs-plugin
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

NPM Version Package License NPM Downloads Built with TypeScript

GrapesJS Chart.js Plugin

This plugin integrates Chart.js into your GrapesJS editor 🚀🚀. You can add various types of charts 📊 to your projects and customize them according to your needs.

DEMO

⭐ Star me on GitHub — it motivates me a lot!

Summary

  • Plugin name: grapesjs-chartjs-plugin
  • Components
    • chartjs
  • Blocks
    • chartjs-bar
    • chartjs-line
    • chartjs-pie
    • chartjs-doughnut
    • chartjs-polarArea
    • chartjs-radar
    • chartjs-bubble
    • chartjs-scatter

Options

Option Description Default
chartjsOptions This object will be passed directly to the underlying Chart.js options. See here for more info. { maintainAspectRatio: false }
blocks Which blocks to add. [ "chartjs-bar", "chartjs-line", "chartjs-pie", "chartjs-doughnut", "chartjs-polarArea", "chartjs-radar", "chartjs-bubble", "chartjs-scatter" ]
category Category name. By default the category value of the i18n en locale file will be used. { id: 'chartjs', label: "Charts" }
i18n Object used to translate plugin properties. Check the en locale file and follow its inner path. en

Download

  • CDN
    • https://unpkg.com/grapesjs-chartjs-plugin
  • NPM
    • npm i grapesjs-chartjs-plugin
  • GIT
    • git clone https://github.com/fasenderos/grapesjs-chartjs-plugin.git

Usage

Directly in the browser

<link
  href="https://unpkg.com/grapesjs/dist/css/grapes.min.css"
  rel="stylesheet"
/>
<script src="https://unpkg.com/grapesjs"></script>
<script src="https://unpkg.com/grapesjs-chartjs-plugin"></script>

<div id="gjs"></div>

<script type="text/javascript">
  var editor = grapesjs.init({
    container: "#gjs",
    // ...
    plugins: ["grapesjs-chartjs-plugin"],
    pluginsOpts: {
      "grapesjs-chartjs-plugin": {
        /* options */
      },
    },
  });
</script>

Modern javascript

import grapesjs from 'grapesjs';
import plugin from 'grapesjs-chartjs-plugin';
import 'grapesjs/dist/css/grapes.min.css';

const editor = grapesjs.init({
  container : '#gjs',
  // ...
  plugins: [plugin],
  pluginsOpts: {
    [plugin]: { /* options */ }
  }
  // or
  plugins: [
    editor => plugin(editor, { /* options */ }),
  ],
});

Development

Clone the repository

$ git clone https://github.com/fasenderos/grapesjs-chartjs-plugin.git
$ cd grapesjs-chartjs-plugin

Install dependencies

$ npm i

Start the dev server

$ npm start

Build the source

$ npm run build

License

MIT

Package Sidebar

Install

npm i grapesjs-chartjs-plugin

Weekly Downloads

27

Version

0.2.0

License

MIT

Unpacked Size

102 kB

Total Files

10

Last publish

Collaborators

  • fasenderos