MyThemeWay / mtw-boilerplate-charts

Combo of esbuild, Chart.js... to develop/build quickly + easily chart canvas bundles. Minimized bundles can be embedded on a website and the chart's datasets continuously updated automatically - Demo:

Home Page:https://mythemeway.github.io/mtw-boilerplate-charts/mtw-chart-bubble

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MTW-BOILERPLATE-CHARTS





Snyk Vulnerabilities
 pending...
Full Report: Last One


This boilerplate allows you to develop quickly and easily chart canvas bundles. It has two modes. The result of production mode is a minimized bundle. You can embed this bundle on a website and then automatically update the chart's datasets continuously, for example.

In development mode, the chart files are watched. This means, if you edit them and save your changes, the charts will be recompiled and reloaded immediately. Feel free to adapt the existing charts or create a completely new one. If you need inspiration, check out Chart.js Samples or Awesome Chart.js. There you can see what's possible.

| Chart Canvas Examples

mtw-chart-bubble.mp4
mtw-chart-polar.mp4
mtw-chart-bar.mp4
mtw-chart-line.mp4

Note:


| Feature Overview

Node.js esbuild Chart.js terser

Note: Badges are clickable and linked to their sources.

Additional Feature Information:

[click to toggle]

Note: Cards are clickable and linked to the corresponding GitHub repositories.


| Setup

To enable local operation of this boilerplate, you can do the following:

  1. open your terminal and define your startup file MYSTARTUPFILE in use
    • e. g. for Zsh
       MYSTARTUPFILE=".zshrc"
    • or for pure Bash
       MYSTARTUPFILE=".bashrc" # or .bash_profile for macOS
  2. install nvm and source your startup file again
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
    source ~/$MYSTARTUPFILE
  3. if your terminal has closed, open it again and continue
  4. execute nvm install --lts to install Node.js
  5. clone the repository git clone https://github.com/mythemeway/mtw-boilerplate-charts or your fork to your local machine
  6. change your current directory to mtw-boilerplate-charts cd mtw-boilerplate-charts
  7. run npm install

Note: If you've already installed Node.js LTS you only have to do steps 5-7.

That's it.


| Boilerplate Usage

Run Development Mode

Go to the mtw-boilerplate-charts directory on your local machine and execute npm start. The result will appear at e. g. http://localhost:8080.

Run Production Mode

There are two ways to get your minimized bundle.

Way 1: npm run build = without terser [default] [faster]

Way 2: npm run terser = with terser additionally [smaller]

Note: output directory is always ~/mtw-boilerplate-charts/dist

Embed Chart

<div style="position:relative; height:40vh; width:80vw">
	<canvas id="mtw-canvas"></canvas>
</div>
<script src="./canvas.bundle.min.js"></script>

Note: responsive charts require special embedding treatment

Switch Chart

  1. open ~/mtw-boilerplate-charts/canvas.config.js
  2. change const canvas and save it
    // 
    // CANVAS SETTINGS
    //  - path:  path to canvas
    //  - id:    canvas id attribute
    //  
    
    // const canvas = { path: './src/chartjs/mtw-chart-line.js', id: 'mtw-canvas' };
    // const canvas = { path: './src/chartjs/mtw-chart-bar.js', id: 'mtw-canvas' };
    const canvas = { path: './src/chartjs/mtw-chart-polar.js', id: 'mtw-canvas' };
    // const canvas = { path: './src/chartjs/mtw-chart-bubble.js', id: 'mtw-canvas' };
    
    module.exports = canvas;

Add Chart

  1. put mtw-chart-new.js into the ~/mtw-boilerplate-charts/src/... directory
  2. follow the switch chart procedure
    // 
    // CANVAS SETTINGS
    //  - path:  path to canvas
    //  - id:    canvas id attribute
    //  
    
    // const canvas = { path: './src/chartjs/mtw-chart-line.js', id: 'mtw-canvas' };
    // const canvas = { path: './src/chartjs/mtw-chart-bar.js', id: 'mtw-canvas' };
    // const canvas = { path: './src/chartjs/mtw-chart-polar.js', id: 'mtw-canvas' };
    // const canvas = { path: './src/chartjs/mtw-chart-bubble.js', id: 'mtw-canvas' };
    const canvas = { path: './src/chartjs/mtw-chart-new.js', id: 'new-canvas' };
    
    module.exports = canvas;

Note:

  • your canvas id attribute setting is only used in production mode; in development mode it is always the default mtw-canvas

  • if you switch/add a chart in development mode, the result is displayed immediately after saving your changes


| Other Boilerplates


| Appendix

Note on protected brand names and logos

  • The use of protected brand names, trade names, utility models and brand logos on this website does not constitute an infringement of copyright; rather, it serves as an illustrative note. Even if this is not marked as such at the respective points, the corresponding legal provisions always apply.

  • The brand names and logos used are the property of their respective owners and are subject to their copyright provisions.

  • This offer is in no way related to the legal entities of the protected brand names and logos used.

Note on liability for links

  • This README contains links to external third-party websites. The README operator has no influence on the content of these sites. Therefore, he cannot assume any liability. Instead, the respective provider is always responsible for the content.

  • The linked pages were checked for possible legal violations at the time of linking and illegal content wasn't discernible. A permanent control of the linked pages is unreasonable without concrete evidence of an infringement. However, if the README operator becomes aware of such a violation, he will act immediately.

Readme uses

About

Combo of esbuild, Chart.js... to develop/build quickly + easily chart canvas bundles. Minimized bundles can be embedded on a website and the chart's datasets continuously updated automatically - Demo:

https://mythemeway.github.io/mtw-boilerplate-charts/mtw-chart-bubble

License:MIT License


Languages

Language:JavaScript 100.0%