A Beginner’s Guide to Chart.js
stanleyulili.com
A Beginner’s Guide to Chart.js
1–10 of 45 posts
Re: A Beginner’s Guide to Chart.js
#2This is how the Chart.js code begins:
(function (global, factory) {
typeof exports === 'object' && typeof module !==
'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ?
define(factory) :
(global.Chart = factory());
}(this, (function () { 'use strict';
... now comes all the code ...
I have no idea how to read this, what this means and how to invoke a construct like this.Re: A Beginner’s Guide to Chart.js
#3Now that we have Javascript modules, is all this trickery on top of a library like this one still needed? This is how the Chart.js code begins: (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.Chart = factory()); }(this, (function () { 'use strict'; ... now comes all the code…
Re: A Beginner’s Guide to Chart.js
#4Now that we have Javascript modules, is all this trickery on top of a library like this one still needed? This is how the Chart.js code begins: (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.Chart = factory()); }(this, (function () { 'use strict'; ... now comes all the code…
That is an UMD bundle. What is more disappointing is that Chartjs itself seems to be written in ES5.
Change to ES modules would be welcome though.
Re: A Beginner’s Guide to Chart.js
#5Re: A Beginner’s Guide to Chart.js
#6Nowadays I prefer Apexcharts.js, which renders to SVG.
https://github.com/apexcharts/apexcharts.js (MIT License)
Re: A Beginner’s Guide to Chart.js
#7Now that we have Javascript modules, is all this trickery on top of a library like this one still needed? This is how the Chart.js code begins: (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.Chart = factory()); }(this, (function () { 'use strict'; ... now comes all the code…
If the library is imported in the way that the article recommends in step two, it's not actually loaded as an ES6 module. This code checks to see if we're currently acting as a module and accordingly makes sure that the library is available as a global object. See this link for some examples: https://devhints.io/umdjs
> I have no idea how to read this ...
I tried to add some comments [0] which will hopefully help!
[0] https://gist.github.com/tjwds/8883b20d5981518bad66497f0466ac...
Re: A Beginner’s Guide to Chart.js
#8Now that we have Javascript modules, is all this trickery on top of a library like this one still needed? This is how the Chart.js code begins: (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global.Chart = factory()); }(this, (function () { 'use strict'; ... now comes all the code…
> is all this trickery on top of a library like this one still needed? If the library is imported in the way that the article recommends in step two, it's not actually loaded as an ES6 module. This code checks to see if we're currently acting as a module and accordingly makes sure that the library is available as a global object. See this link for some examples: https://devhints.io/umdjs > I have no idea how to read…
As a module:
As a module dependency: import * as chart from 'Chart.js';Re: A Beginner’s Guide to Chart.js
#9Chart.js still uses the HTML Canvas element, so charts generated with it look blurred when printed or zoomed in. Nowadays I prefer Apexcharts.js, which renders to SVG. https://github.com/apexcharts/apexcharts.js (MIT License)
Re: A Beginner’s Guide to Chart.js
#10Chart.js still uses the HTML Canvas element, so charts generated with it look blurred when printed or zoomed in. Nowadays I prefer Apexcharts.js, which renders to SVG. https://github.com/apexcharts/apexcharts.js (MIT License)