[Chartjs]-Ng2Charts/chart.js changing chart type for one is impacting many charts

2👍

To see working code here

The issue was because the selected value was stored at the level of category… however the choices were being made at the level of the question… this is why the first and third chart data was reading the same ‘type’ and second and fourth charts were reading the same ‘type’

According to the hierarchy of data:

  • category > question > unique-chart
  • category (previously selected value was stored here) > question > unique-chart
  • category > question (now selected value is stored here) > unique-chart

see this selectedType field added here, at the individual question level

onChange function

onChange(event, ix, iy) {
    console.log("for:" + ix + " & " + iy + ", selected type" + event.target.value);
    this.selectedType[iy] = event.target.value;
    this.evaluationModel[0].category[ix].question[iy].selectedType = event.target.value;
  }

Leave a comment