-
Notifications
You must be signed in to change notification settings - Fork 11.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Charts as modules #4461
Comments
Definitely a good enhancement to consider that makes some things simpler. Would definitely be a breaking change though |
@simonbrunel said in #4303 that he was going to cleanup the modules and switch them to ES6. Would we want to implement something like this as part of that change? |
@etimberg, not necessary a breaking change, this can be completely optional, as it is now a days with https://github.com/ReactiveX/rxjs |
The breaking change is that right now we have no concept of a different class for each chart type. I'm wary of breaking things with a change that introduces that For example, would these return the same classes? var mychart = new Chart(ctx, {
type: 'pie'
});
var mychart = new PieChart(ctx, {}); Another potential question: how would we handle mixed chart types? |
I believe the API doesn't need to change in order to have partial imports. For example, RxJS have more then one usage approach for it, one of then is the follow: import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/map';
Observable.of(1,2,3).map(x => x + '!!!'); // etc Chart.js could use a similar approach like: import { Chart } from 'Chart.js/Chart';
import 'Chart.js/add/pie';
var mychart = new Chart(ctx, {
type: 'pie'
}); |
@willgm that style of imports would definitely work well with our code. We could even do the same for importing new scale types (log, time, etc). |
I found a workaround for this issue. The code is on Typescript:
Then:
ChartJS is on package.json |
When will 3.0 arrive? Any beta available? BTW: Here is a related closed issue: #5179 |
I placed a comment in #5179 (comment) which shows how to build a module from chart.js via a rollup with chart.js as a commonjs module. Let me know if it works for you. Bottom line: with a simple rollup.config and two plugins, chart.js seems to be converted to an esm. |
I'm closing this in favor of #7371 which has much more information on the current state of things and how it could be implemented. We'd love volunteers to help with it. As much as I'd love to see it, I'm not sure it'll make it into 3.0 without someone stepping up to implement it |
I think that a modern chart library should work in the following way:
import PieChart from 'chart/pie';
new PieChart(/necessary stuff/);
Prós:
What you think guys?
Thanks.
The text was updated successfully, but these errors were encountered: