Skip to content
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

Simplify scale registration #7009

Closed
wants to merge 2 commits into from

Conversation

benmccann
Copy link
Contributor

@benmccann benmccann commented Jan 23, 2020

This would make it much easier to register a scale. You only need to pass the scale and can pass multiple at once if you want I'm not sure I prefer this route, but thought it would be helpful for visualizing the differences between the approaches

@kurkle had suggested over Slack that as an alternative to #6979 to support tree shaking we create a separate entry point for npm such as index.es6.js and don't do the auto-registration.

Option 1

We might be able to use this register controllers as well, which would also be needed for tree shaking. I'm imagining you'd want to do something like:

import {registrationService, TimeScale, LinearScale, LineController} from 'chart.js';
registrationService.register(TimeScale, LinearScale, LineController);

Option 2

If you have auto-registration you wouldn't want to have an entry point that imports everything, so you'd want to import the modules, but wouldn't need to register, so it'd end up looking like:

import TimeScale from 'chart.js/scale.time';
import LinearScale from 'chart.js/scale.linear';
import LineController from 'chart.js/controller.line';

Option 3

Another option would be to remove the registration and pass the constructor type directly in the opions:

import TimeScale from 'chart.js/scale.time';
const options = {
  scales: {
    x: {
      type: TimeScale
    }
  }
};

@benmccann
Copy link
Contributor Author

Closing for now. I may revisit later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant