事件中没有angularjs融合图表工作图表、工作、事件中、angularjs

2023-09-13 04:16:51 作者:该用户不存在

我试图采用了棱角分明捕捉到 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