nagix / chartjs-plugin-colorschemes

Predefined color schemes for Chart.js
MIT License
271 stars 59 forks source link

This doesn't work #4

Closed blockjon closed 5 years ago

blockjon commented 5 years ago

I love the idea behind this project... unfortunately I just tried it and it doesn't work. I followed the directions exactly as described and all of my metrics are all grey colored. There are also no errors.

chart.js version 2.7.3 chartjs-plugin-colorschemes version 0.1.0 installed with npm using react

image

image

blockjon commented 5 years ago

I must be doing something wrong.. not importing something correctly etc. Are there any examples of how to use this in es6 with react?

blockjon commented 5 years ago

🤔 answered my own question: If I add this at the top of my file, it works:

import * as name from "chartjs-plugin-colorschemes";
nagix commented 5 years ago

Good to know that you have already solved the issue. For React, just import 'chartjs-plugin-colorschemes'; is fine.

osterland commented 5 years ago

do you know by any chance how to import colorschemes for an angular2+ project? I got many errors every way i try

Thank you very much in advance

nagix commented 5 years ago

import 'chartjs-plugin-colorschemes'; works in an Angular 2+ project as well.

osterland commented 5 years ago

thank you for your answer - i tried this ofc but no luck.

Iam starting to think - is this maybe for linecharts only? ;)

efriandika commented 5 years ago

yes same here.. It does not works in angular 7.x I use pie chart..

Any idea ?

nagix commented 5 years ago

@osterland @efriandika Regarding Angular, if you are using this plugin with ng2-charts, it does not work because a color scheme is applied only when no colors are defined in a chart config but ng2-charts has default colors. In order to workaround this, I have added the override option in 20c60e5, which enables to override the existing color settings with the specified color scheme. This change will be available in the next v0.4.0 release.

felipefialho commented 5 years ago

thanks @nagix

alanhyue commented 4 years ago

Had the same issue when using with Vue.js. @blockjon 's solution works. import * as name from "chartjs-plugin-colorschemes";

But I do not understand why the instruction import "chartjs-plugin-colorschemes" doesn't work. It seems to be a difference in the mechanism of importing modules. I am still new to JS, I would love to hear if anyone have identified the reason.