Chartjs-Updating Chartjs Data with Response from POST Call?

0👍

When data is a function, is it invoked with node where the chart is mounted. However you don’t seem to be having need for it currently.

Declare data to receive Server response data.

  dataFactory: data => {
    return {
      datasets: [
        {
          label: ' Total Value',
          data,
          backgroundColor: '#C4D156'
        }
      ]
    };
  },

Then invoke it in render method of your component with data stored in state.

<HorizontalBar
  data={stackedChart.dataFactory(this.state.RESTresponse)}
  options={stackedChart.options}
/>
 

Leave a comment