0.1.2 • Published 4 months ago

grapesjs-chartjs-plugin v0.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

GrapesJS Chart.js Plugin

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

DEMO

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

OptionDescriptionDefault
chartjsOptionsThis object will be passed directly to the underlying Chart.js options. See here for more info.{ maintainAspectRatio: false }
blocksWhich blocks to add.[ "chartjs-bar", "chartjs-line", "chartjs-pie", "chartjs-doughnut", "chartjs-polarArea", "chartjs-radar", "chartjs-bubble", "chartjs-scatter" ]
categoryCategory name. By default the category value of the i18n en locale file will be used.{ id: 'chartjs', label: "Charts" }
i18nObject 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