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

All Scales should be extensible #3662

Closed
geo-developer opened this issue Nov 30, 2016 · 5 comments
Closed

All Scales should be extensible #3662

geo-developer opened this issue Nov 30, 2016 · 5 comments

Comments

@geo-developer
Copy link

From the website we have this:

Writing New Scale Types

Starting with Chart.js 2.0 scales can be individually extended. Scales should always derive from Chart.Scale.

So i assumed that every scale type you have should be extensible, but the only extensible ones are Scale and LinearScaleBase.

I don't really know if it is a bug or just as is, but if it is a bug you just have to change every scale you have apart from the LinearScaleBase, to instead of having the Scales as vars you need to add them to Chart namespace.

I got into this issue because i wanted to extend the TimeScale to change a function to fit my data, but i couldn't because it wasn't on Chart namespace, so i just copied the TimeScale you have in src/ to solve the problem.

Thanks and awesome library guys,
Pedro

@etimberg
Copy link
Member

@geo-developer you can get the otger scales. The scaleService has a lookup function to get the constructor.

@geo-developer
Copy link
Author

@etimberg thanks i'm going to check that.
Btw is it a bug or intended? Just asking because on docs you only show one way of extending.

Thanks again,
Pedro

@etimberg
Copy link
Member

It's intended. When writing a custom scale, the scaleService is used to register the type. The lookup function is called getScaleConstructor(type) where type is the string type like 'linear' or 'time'

@geo-developer
Copy link
Author

@etimberg Thanks again for the explanation, it works like a charm.

Maybe update docs in Writing New Scale Types to contain this option?
Just asking because in docs we can only see the extension of the base Scale.

Thanks again,
Pedro

@etimberg
Copy link
Member

I believe this is fixed in #3751 as part of the new docs

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

No branches or pull requests

2 participants