Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

Reduce the Chart constructor and use inheritance?

Open phloe opened this issue 13 years ago • 2 comments

Instead of declaring all of the generic variables and functions on every instantiation of Chart - wrap everything in an IIFE that returns the constructor and move the variables/functions outside the contructor. I tried this in a fork: https://github.com/rasmusfl0e/Chart.js/blob/master/Chart.js

Also: consider having Pie et al inherit from Chart so they automatically get context/width/height etc without having to pass them around.

phloe avatar Mar 18 '13 10:03 phloe

++. Oddly, I did start just that in my fork-- for ideas:

Base: https://github.com/DimitarChristoff/chrt/blob/master/js/chrt/chrt-new.js Pie: https://github.com/DimitarChristoff/chrt/blob/master/js/chrt/pie.js

Still undecided on api and events, adding kinetic.js possibly also. Not at all suggesting use, prime/requirejs is for my own consumption.

DimitarChristoff avatar Mar 21 '13 00:03 DimitarChristoff

Yeah inheritance is a big part of the new version - opened up an API for creating new chart types as well, and abstracted some common shapes/elements into reusable classes there.

nnnick avatar Jun 29 '14 19:06 nnnick