fusioncharts / angularjs-fusioncharts

AngularJS Directive for FusionCharts JavaScript Charting Library (for Angular 1.x)
https://fusioncharts.github.io/angularjs-fusioncharts/
MIT License
111 stars 101 forks source link

line not drawing in mscombi2d #47

Open GuusPunt opened 6 years ago

GuusPunt commented 6 years ago

linenotvisible linevisible

I've created my first chart after a day testing. It's a combi chart (2 bar series , 1 line serie)

After updating the datasource from my controller, the bar series always get drawn and updated. However the line does not.

The line chart gets updated/drawn random( 50% visible, 50% not visible)

Update: vm.myDataSource.dataset[2].data = [{"value":"16610.88"},{"value":"16610.88"},{"value":"16610.88"},{"value":"16610.88"},{"value":"41524.72"},{"value":"1.66"},{"value":"1.66"},{"value":"1.66"},{"value":"1.66"},{"value":"1.66"},{"value":"-8302.95"},{"value":"-8302.95"}];

I print my bar data after every update : console.log(JSON.stringify(vm.myDataSource.dataset[2].data));

It shows the exact data from the dataset every time but the line not always get drawn. Any hints or clue's would be appreciated. Addionatinol info needed plz let me know.

(Not an angular expert )

GuusPunt commented 6 years ago

lineshowvalues_true

I have enabled the showValues value on the line series. Now the values of the line are drawn in the chart, but the line is not visible.

rousan commented 6 years ago

Hi @GuusPunt,

Can you provide samples code to produce the same at our end?

GuusPunt commented 6 years ago

Hi @rousan .

I'm quite new to github, in which form would be the best to provide the sample code?

PS: The charts draw perfect when i start an timer in the angularjs controller init function instead of calling a service and setting the response instant to the datasource of the chart. My problems is kind of solved but im still wondering what causes the difference between the two differents approaches as shown below.

---- Line not drawn, bars drawn ----

function initController() {
        CashflowService.GetCurrentRateChart('2018')
        .then(function(result){
          if(result.success){
            vm.currentRateChart.dataset[0].data     = result.incoming;
            vm.currentRateChart.dataset[1].data     = result.outgoing;
            vm.currentRateChart.dataset[2].data     = result.cashisking;
          }
        });
    }

---- Perfectly working example ----

    function initController() {
        startUpdatingCharts();
    }

   var updateCharts;
   function startUpdatingCharts (){
    updateCharts = $interval(function() {
        updateCurrentRate();
    }, 1000);
   }

   $scope.stopUpdatingCharts = function() {
    if (angular.isDefined(updateCharts)) {
        $interval.cancel(updateCharts);
        updateCharts = undefined;
    }
   };

   $scope.$on('$destroy', function() {
    // Make sure that the interval is destroyed too
    $scope.stopUpdatingCharts();
   });

function updateCurrentRate(){
    console.log("updating current rate chart");
    CashflowService.GetCurrentRateChart('2018')
    .then(function(result){
      if(result.success){
        vm.currentRateChart.dataset[0].data     = result.incoming;
        vm.currentRateChart.dataset[1].data     = result.outgoing;
        vm.currentRateChart.dataset[2].data     = result.cashisking;
      }
    });
  }