事件中没有angularjs融合图表工作 [英] events is not working in angularjs fusion charts

查看:166
本文介绍了事件中没有angularjs融合图表工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图采用了棱角分明捕捉到 dataplotClick 事件融合图表pie2d图。我指的这个例子条形图与事件的。当我创建对象事件直接将范围那么它的工作。

I am trying to capture dataplotClick event in pie2d chart of fusion charts using angular. I'm referring this example Bar chart with events. When I create object events directly to the scope then it's working.

工作

$scope.events = {
                        dataplotClick:function(evnt,data) {
                            var lbl = data.toolText.split(",")[0];
                            console.log(lbl);
                            $scope.$apply(function() {
                                $scope.stFilter = {'EV_STATE_NUMBER':lbl};
                            });
                        }
                    }

不工作

$scope.my = {};
$scope.my.events = {
                    dataplotClick:function(evnt,data) {
                        var lbl = data.toolText.split(",")[0];
                        console.log(lbl);
                        $scope.$apply(function() {
                            $scope.stFilter = {'EV_STATE_NUMBER':lbl};
                        });
                    }
                }

HTML

<fusioncharts 
      width="90%" 
      height="100%"
      type="pie2d"
      datasource="{{fcb.effiPerformance}}"
      events="my.events" // Not working
      events="events" // Working
> </fusioncharts>

由于我在多个图表纳克重复,我必须附上事件的功能为他们每个人。帮助我,如果任何人知道如何去实现它。

As I have more than one charts inside ng-repeat, I have to attach event function for each of them. Help me if anyone knows how to achieve it.

推荐答案

在FusionCharts的角度插件可以访问控制器范围内,只有直子对象。
请参考以下code从的https://github.com/fusioncharts/angular-fusioncharts/blob/master/src/angular-fusioncharts.js.

The FusionCharts angular plugin can access only the direct child objects inside the controller scope. Refer to the following code at line 346 of the source code from https://github.com/fusioncharts/angular-fusioncharts/blob/master/src/angular-fusioncharts.js.

if (scope.$parent[attrs.events]) {

要定义不同的图表里面相同的控制器可以定义不同的事件对象的名称不同的事件。例如.-

To define different events for different charts inside same controller you can define different event object names. e.g.-

//Controller
$scope.chart1_events = {
      dataplotClick:function(evnt,data) {
          var lbl = data.toolText.split(",")[0];
          console.log(lbl);
          $scope.$apply(function() {
              $scope.stFilter = {'EV_STATE_NUMBER':lbl};
          });
      }
}

//HTML
<fusioncharts 
  width="90%" 
  height="100%"
  type="pie2d"
  datasource="{{fcb.effiPerformance}}"
  events="chart1_events"
> </fusioncharts>

http://jsfiddle.net/ayanonly1/57gxf5e1/

更新: - 这个问题是固定在插件的V3.0

这篇关于事件中没有angularjs融合图表工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆