nagix / chartjs-plugin-colorschemes

Predefined color schemes for Chart.js
MIT License
263 stars 58 forks source link

New Release with compatibility Chart.js v3 #28

Open DmytroLitvinov opened 3 years ago

DmytroLitvinov commented 3 years ago

After merging https://github.com/nagix/chartjs-plugin-colorschemes/pull/26 it would be nice to see it as npm package's release :)

nagix commented 3 years ago

I will update the build system, workflows and documentation, add TypeScript support, improve ES module support, then release v1 😉

marti1125 commented 3 years ago

When we will can get the new release for chartjs v3?

matheusft commented 3 years ago

What is the latest Chart.js compatible version? I'm building a Flask application and my charts go all grey when I use any version of Chart.js after 2.9.4. Thanks 😀

berthin commented 2 years ago

I was playing a bit with colorscheme v0.4.0 + Chart.js, and until v2.9.4 the plugin seems to work, but for newer versions (+3.0.2), colorscheme is broken with the following error:

 Uncaught TypeError: f.defaults.global is undefined
    <anonymous> https://cdn.jsdelivr.net/npm/chartjs-plugin-colorschemes@0.4.0:7
    <anonymous> https://cdn.jsdelivr.net/npm/chartjs-plugin-colorschemes@0.4.0:7
    <anonymous> https://cdn.jsdelivr.net/npm/chartjs-plugin-colorschemes@0.4.0:7
drkelly58 commented 2 years ago

@nagix Any idea of a release date for v1?

yurij7070 commented 2 years ago

Hello! Master branch does not work with Chart.js 3.5.1 I've correct plugin.colorschemes.js, line 184 Replace Chart.plugins.register(ColorSchemesPlugin); to (Chart.plugins || Chart).register(ColorSchemesPlugin); After this replacement chartjs-plugin-colorschemes works well with Chart.js 3.5.1

Cyrille37 commented 2 years ago

Hi. I think it's not enough:

Uncaught TypeError: Chart.defaults.global is undefined
it-mkl commented 2 years ago

I encountered the same same issues. I was able to get it working with chart.js 3.5.1 by applying the above patch, but also: Line 1040 change: Chart.defaults.global.plugins.colorschemes to Chart.defaults.plugins.colorschemes

Line 1075 - beforeUpdate: added following new line to get plugin options from chart object (as they were not present in argument options): var options = chart.config.options.plugins.colorschemes;

pizzo00 commented 2 years ago

Also replace Chart.plugins.register(ColorSchemesPlugin); with Chart.register(ColorSchemesPlugin); on line 1189

s4m0r4m4 commented 2 years ago

@nagix With #26, it's technically not a breaking change as far as I know. Would you consider releasing a 0.5.0 for Chart.js 3 compatibility? I know it would be nice to bundle this update into the v1.0 release, but perhaps it's just time to get Chart.js 3 support out there.

s4m0r4m4 commented 2 years ago

I think this may help resolve ChartJs 3 compatibility: https://github.com/nagix/chartjs-plugin-colorschemes/pull/30, check it out and make sure it's working!

ger82 commented 2 years ago

I think there is one more problem with the typ 'bar'.

in beforeUpdate the forEach which should set scheme colors, it set only the first color

nicohlr commented 2 years ago

@nagix do you have any idea when the next release can be released with compatibility with chart.js 3.X.X ? Thanks

viktorsmari commented 2 years ago

Sorry for insisting, @nagix do you know when you have time for a new release? :smile:

Cyrille37 commented 2 years ago

Hello @nagix if you no more have time, perhaps you can add one or two people with write access to this repo, that make update alive :-)

devozanges commented 2 years ago

"I will update the build system, workflows and documentation, add TypeScript support, improve ES module support, then release v1" Will it be done in 2022 ? at least support for v3... thanks

sdespont commented 2 years ago

@nagix Any idea of a release date for v1? Supporting Chart.js V3 becomes important for many projects and avoid using this plugin for compatibility problem is wasted your work,

simonbuehler commented 1 year ago

just a 👍 for your great work combined with a tiny

please release V3 support

tl-sfo commented 1 year ago

In issue #33 jayantbh has written

https://www.npmjs.com/package/hw-chartjs-plugin-colorschemes

This seems to be a fork published to work with chartjs v3.

Indeed, this fork works with ChartJS 3.x, but has another bug.

If I use this ChartJS config

{
  type: 'bar',
  data: {
    labels: ['diagramLabel'],
    datasets: [{
      label: 'dataLabel',
      data: [1],
      backgroundColor: '#00FF00'
    }]
  },
  options: {
    plugins: {
      colorschemes: {
        scheme: 'brewer.YlGn3'
      }
    }
  }
}

the resulting data bar has not the configured background-color #00FF00. It displays it in some "light yellow". If i remove the options section (the colorscheme configuration) then it uses some other color ("light blue"), but still not #00FF00.

Can someone reproduce and confirm it?

In ChartJS 2.x with the unpatched colorscheme-plugin it works.