1 year ago

#381067

test-img

Fahad Iftikhar

Replot Series in amcharts 4 using angular

everyone I am using amcharts 4 with angular 12 I am developing a Real-time application with real-time data I have one scenario I have two unit changes m(meter) and ft(feet) default unit is meter when I update my unit to ft or ft into m. all series in the chart need to be replotted.

error in console: ERROR Error: EventDispatcher is disposed

What I have done:
I created a function that is subscribing/watching unit when it detects a changed unit it disposes of all charts series and recall all series function, but it gives me the error in the console.

detectUnitChange() {

    this.realTimeDataService
      .getRealTimeDepthTaggedInclination()
      .subscribe((res) => {
        if (res.hasException) {
          this.errorHandlingService.setError(
            this.errors,
            DataChannels.RealTimeDepthTaggedInclination,
            res.exception.message
          );
        } else {
           var checkUnit = res.value;
           // detect unit set change and update title and replot curve
           if(this.YaxisUnit !== checkUnit.depth.unit){
                this.XaxisUnit = checkUnit.value.unit;
                this.YaxisUnit = checkUnit.depth.unit;
                this.yAxis.title.text = "Measured Depth " + "[[" + this.YaxisUnit + "]]";
                this.xAxis.title.text = "Inclination " + "[[" + this.XaxisUnit + "]]";
                for (let index = 0; index < this.chart.series.length; index++) {
                  this.chart.series.removeIndex(index);
                }
                this.assignRealTimeData();
                this.assignPlannedData();
                this.assignSurveyData();
                this.assignCurrentPredictedData();
                this.assignOptimizedPredictedData();
                this.assignRotationalAzimuthData();
           }
        }
     });
  }

angular

series

amcharts4

0 Answers

Your Answer

Accepted video resources