AmStockCharts updateChart:无法设置属性&溢出'未定义的

时间:2018-06-08 18:15:09

标签: javascript html angularjs sails.js

我使用的是带风帆0.12.14的angularJS。我正在从模型函数中读取一些数据,并且我试图将它们添加到angular的dependencie / angular / controller / myArquive.js中。

基于此示例: https://www.amcharts.com/demos/line-chart-with-scroll-and-zoom/?theme=dark

但是当您运行函数所在的文件时,会显示此错误。

Uncaught (in promise) TypeError: Cannot set property 'overflow' of undefined
at b.afterWrite (amcharts.js:4)
at b.write (amcharts.js:4)
at Object.d.makeChart (amcharts.js:1)
at Promise (acuracia_experimentoV2.js:106)
at new Promise (<anonymous>)
at iDistributionChart (acuracia_experimentoV2.js:102)
at $scope.load.loadChart.then.res (acuracia_experimentoV2.js:25)

这是此图表的主要代码。

&#13;
&#13;
app.controller("acuraciaExperimentoV2", ['$scope', 'ConsTest', '$timeout', '$http', function ($scope, ConsTest, $timeout, $http) {
  $scope.showTestDetail = function (param) {  
    $scope.load = loadChart().then(res => {
      iDistributionChart(res).then(resChart => {
        resChart.addListener("rendered", zoomChart);
        zoomChart();
        function zoomChart() {
          resChart.zoomToIndexes(chartData.length - 40, chartData.length - 1);
        }
      });
    });
  }
  function iDistributionChart(chartData) {
    return new Promise((resolve, reject) => {
      var ctx = document.getElementById('intentDistributionChart').getContext('2d');
      var chart = AmCharts.makeChart(ctx, {
        "type": "serial",
        "theme": "dark",
        "marginRight": 80,
        "autoMarginOffset": 20,
        "marginTop": 7,
        "dataProvider": chartData,
        "valueAxes": [{
          "axisAlpha": 0.2,
          "dashLength": 1,
          "position": "left"
        }],
        "mouseWheelZoomEnabled": true,
        "graphs": [{
          "id": "g1",
          "balloonText": "[[value]]",
          "bullet": "round",
          "bulletBorderAlpha": 1,
          "bulletColor": "#FFFFFF",
          "hideBulletsCount": 50,
          "title": "red line",
          "valueField": "visits",
          "useLineColorForBulletBorder": true,
          "balloon": {
            "drop": true
          }
        }],
        "chartScrollbar": {
          "autoGridCount": true,
          "graph": "g1",
          "scrollbarHeight": 40
        },
        "chartCursor": {
          "limitToGraph": "g1"
        },
        "categoryField": "date",
        "categoryAxis": {
          "parseDates": true,
          "axisColor": "#DADADA",
          "dashLength": 1,
          "minorGridEnabled": true
        },
        "export": {
          "enabled": true
        }
      });
      resolve(chart);
    });
  }
  function loadChart() {
    return new Promise((resolve, reject) => {
      var chartData = [];
      var firstDate = new Date();
      firstDate.setDate(firstDate.getDate() - 5);
      var visits = 1200;
      for (var i = 0; i < 1000; i++) {
        var newDate = new Date(firstDate);
        newDate.setDate(newDate.getDate() + i);
        visits += Math.round((Math.random() < 0.5 ? 1 : -1) * Math.random() * 10);
        chartData.push({
          date: newDate,
          visits: visits
        });
      }
      resolve(chartData);
    });
  }
}]);
&#13;
&#13;
&#13;

我不知道如何解决这个问题,我尝试了很多,我研究了很多,我发现最接近的是下面的链接,这也没用。

AmStockCharts updateChart: Cannot set property 'dataContext' of undefined

0 个答案:

没有答案