AmCharts drillUp链接Uncaught ReferenceError

时间:2017-10-13 09:22:34

标签: javascript angularjs amcharts

这是我的AmChartjs的示例代码,图表的整个代码都很长。

  // check if drill-down data is avaliable
  if ( event.item.dataContext.data !== undefined) {

    // save for back button
    mostSoldChart.drillLevels.push(event.item.dataContext);

    // replace data
    mostSoldChart.dataProvider = event.item.dataContext.data;

    // replace title
    mostSoldChart.titles[0].text = event.item.dataContext.category;

    // add back link
    // let's add a label to go back to yearly data
    event.chart.addLabel(
      70, 10, 
      "< Go back",
      undefined, 
      13, 
      undefined, 
      undefined, 
      undefined, 
      true, 
      'javascript:mostSoldDrillUp();'); // <------------------------------------

    // take in data and animate
    mostSoldChart.validateData();
    mostSoldChart.animateAgain();
  }
});

function mostSoldDrillUp() { // <----------------------------------------------

  // get level
  mostSoldChart.drillLevels.pop();
  var level = mostSoldChart.drillLevels[mostSoldChart.drillLevels.length - 1];

  // replace data
  mostSoldChart.dataProvider = level.data;

  // replace title
  mostSoldChart.titles[0].text = level.category;

  // remove labels
  if (mostSoldChart.drillLevels.length === 1) {
    mostSoldChart.clearLabels();
  mostSoldChart.titles[0].text = 'Most Sold Products';
  }


  // take in data and animate
  mostSoldChart.validateData();
  mostSoldChart.animateAgain();
}

           }   

        }
    }]);

我有一个来自AmCharts网站示例的mostSoldDrillUp函数,它用于drillUp目的或返回到之前的图表显示。

点击后,在控制台的浏览器中输出错误:

未捕获的ReferenceError:未定义mostSoldDrillUp     at:1:1

其他信息:

我把图表放在AngularJS directive

0 个答案:

没有答案