AngularJS Fusion Charts are experiencing issues with events not functioning properly

In my Angular application, I am attempting to capture the dataplotClick event in a pie2d chart of Fusion Charts. I came across an example of a bar chart with events here. When I directly create the events object within the main scope, everything works as expected.

When it works:

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

When it doesn't work:

$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 Markup:

<fusioncharts 
      width="90%" 
      height="100%"
      type="pie2d"
      datasource="{{fcb.effiPerformance}}"
      events="my.events" // Does not work
      events="events" // Works fine
> </fusioncharts>

Since I have multiple charts within an ng-repeat, I need to attach event functions to each of them. Can anyone provide guidance on how to achieve this?

Answer №1

FusionCharts plugin for Angular is capable of accessing only the direct child objects within the controller scope. Take a look at the code snippet on line 346 of the source code available at https://github.com/fusioncharts/angular-fusioncharts/blob/master/src/angular-fusioncharts.js.

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

If you want to define different events for various charts within the same controller, you can assign unique event object names. For example:

//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>

Check out a sample here: http://jsfiddle.net/ayanonly1/57gxf5e1/

Update: The plugin has been updated to version 3.0 to fix this issue.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Angular UI Routing is not compatible with Switch functionality

I am currently working on an Angular app that utilizes Angular UI Routing along with a UI plug-in that features "checkbox switches" based on bootstrap switches. The issue arises when the templates load after the shell page, causing the switches to break a ...

Thymeleaf not triggering JQuery click event

Currently working on a Spring Boot site where I have a list of elements, each containing a link. The goal is to trigger a javascript function when these links are clicked. <div class="col-sm-4" th:each="product : ${productsList}"> <!-- Code... ...

Attempting to grasp the sequence in which setTimeout is ordered alongside Promise awaits

I've been puzzling over the sequence of events in this code. Initially, I thought that after a click event triggered and Promise 2 was awaited, the for loop would resume execution once Promise 1 had been resolved - however, it turns out the outcome is ...

Problem encountered when utilizing the jQuery method .load()

Currently, there is an issue on my website where I am trying to load the content of a PHP file into a <div>. After ruling out any server-side problems, I have come to seek help with this question: Is there anything incorrect in the following code? & ...

The state update does not seem to be affecting the DOM

I've implemented this component in my React app. It updates the state every second, but oddly enough the value <p>{this.state.time}</p> is not changing as expected. When I print the state value, it does change every second. import React f ...

How can I ensure that my rendering only occurs after a full input has been entered? Implementing a delayed render() in ReactJS

Im working on a form that includes Controlled Component text inputs: <input type="text" onChange={(e) => this.props.changeBusiness(e)}/> I'm thinking of rendering the above text input in a separate component. It would be great if I could re ...

The routeLink feature is unable to display the URL dynamically

https://i.sstatic.net/iD53V.png <table class="table"> <thead> <tr> <th>Name</th> <th>Price</th> <th></th> </tr> </thead> ...

IE compatibility with CSS2 selectors

Is there a plugin, preferably jQuery, that can enable the use of CSS2 selectors like 'parent > child' and 'element:first-child' in my stylesheet for IE6, which doesn't seem to support them natively? ...

Error in Google PHP and MySQL integration with Google Maps demonstration using Javascript

I've been working on implementing the Google Maps API Family example called "Using PHP/MySQL with Google Maps" (Example): Initially, I thought it would be a straightforward process with some interesting discussions. However, surprisingly, most of it ...

The Facebook SDK's function appears to be triggering twice

I am currently in the process of integrating a Facebook login button into my website and have made progress, but I have encountered a problem. The Facebook SDK JavaScript code that I am using is as follows: function statusChangeCallback(response) { ...

Ways to update the DOM following modifications to a data attribute

I'm currently working on a small CMS system that handles translations for static pages in multiple languages. The system refreshes and loads translations dynamically, but I've encountered some bugs that are proving difficult to resolve. One issue ...

The initial render of Next.js is not properly loading the CSS files

Encountering an issue with the initial load of the mobile app version; it seems that the CSS of my component covering the page is not loading correctly on the first screen load. However, when resizing to desktop and then switching back to mobile view, the ...

Ways to hide notifications by setting a timer while keeping the delete option visible

Presently, this is the code I am working with using Javascript and Vue.js. I have an array called Messages.length that contains messages. When the x button is clicked, it triggers the "clearMessages(item)" function on the server side. However, I also aim ...

Transmit a data element from the user interface to the server side without relying on the

I have developed a MEAN stack application. The backend of the application includes a file named api.js: var express = require('express') var router = express.Router(); var body = 'response.send("hello fixed")'; var F = new Function (" ...

Tips for eliminating white spaces when text wraps onto a new line

Imagine having the following code snippet. Essentially, I have a layout that needs to display 'vs prev period' with a percentage in the same line. To achieve this, I utilized display: flex. The issue arises when we require the gap between the tw ...

Unpredictable Redirection when URL is Clicked using PHP or Javascript

Looking to send users to a random URL from a specific list? For instance: With 3 URLs available - Google.com, Facebook.com, and Yahoo.com <a href="<?php $sites[array_rand($sites)] ?>">Click here</a> Upon clicking the link, users will ...

Is it possible to incorporate Vue and Vuetify into an existing project that requires IE compatibility?

Currently in the process of enhancing a legacy project with new functionality. The front end is currently relying solely on jQuery for all the webpages. I have been tasked with adding another webpage and would like to incorporate Vuetify + Vue due to the i ...

Looking for assistance in resolving performance problems with numerous elements in AngularJS

I am currently experiencing performance issues with AngularJS, particularly when a large number of "elements" are added to the page. It is taking around 20 seconds for my computer to render the elements in this folder structure. Each folder contains 10 sub ...

Can you explain the {| ... |} syntax in JavaScript to me?

While reviewing a javascript codebase, I stumbled upon a section of code that appears as follows: export type RouteReducerProps = {| error?: Error, isResolving: boolean, isResolved: boolean, hasFailed: boolean, |}; Upon closer inspection, it seem ...

Express.js post method malfunctioning for BMI calculation

Currently, I am working on a BMI calculator application in JavaScript as part of my practice. The app is supposed to take two inputs - weight and height, calculate the BMI, and display the result on the web page. However, after inputting the data and submi ...