reactjs / react-chartjs

common react charting components using chart.js
MIT License
2.93k stars 299 forks source link

v2: Assign all nextProps dataset properties to chart #109

Closed ianks closed 8 years ago

ianks commented 8 years ago

This resolves my issue posted in https://github.com/jhudson8/react-chartjs/issues/84

Essentially, only the data was being updated from the datasets. This PR makes its so all of the properties from the dataset are now assigned to the new chart. This will allow for things like:

  1. Updating a label
  2. Updating a fill color
  3. etc.

It also re-introduces the redraw prop to force a re-render of the canvas.

I have only tested this with the Line chart, so if anyone has any production apps where there make use of Doughnut charts, etc. please give this branch a whirl!

ianks commented 8 years ago

Anyone give this branch a whirl yet?

nrempel commented 8 years ago

I've installed this branch to test out v2 functionality. So far everything works great for me.

Thanks for putting in that effort!

stevewillard commented 8 years ago

It's working great for me, too!

dmhood commented 8 years ago

Works for me as well

gor181 commented 8 years ago

Tested with Doughnuts and Pie charts. Works great!

gor181 commented 8 years ago

@ianks can you make the changes mentioned in comments if you find them suitable? How can I assist?

ianks commented 8 years ago

I'll make the changes when I get home tomorrow.

russelldc commented 8 years ago

Does the new combining feature in v2 work with these changes?

ianks commented 8 years ago

@russelldc I am not sure. I have not tested it. Can you give it a try?

eluciano11 commented 8 years ago

Hi @russelldc, I'm using combined charts with this branch and it works properly.

Example:

screen shot 2016-05-09 at 10 37 39 pm
fscz commented 8 years ago

It still does not work for me. Fix: in core.js

replace

var chartDataset = chart.data.datasets[setIndex];

      for (var property in set) {
        if (set.hasOwnProperty(property)) {
          chartDataset[property] = set[property];
        }
      }

with

var chartDataset = {};

      for (var property in set) {
        if (set.hasOwnProperty(property)) {
          chartDataset[property] = set[property];
        }
      }
      chart.data.datasets[setIndex] = chartDataset;
RezaRahmati commented 8 years ago

I get this error using chartjs:2.1.6

core.js:60 Uncaught TypeError: (intermediate value)[chartType] is not a function
classData.initializeChart @ core.js:60
nesbtesh commented 8 years ago

How do I install chart.js-v2 with npm to help with the testing ?

ianks commented 8 years ago

@nesbtesh add this to your package.json

   "react-chartjs": "git+https://github.com/jhudson8/react-chartjs.git#chartjs-v2",