Leveraging Angular Charts for Retrieving and Implementing Data and Label Values

In my angular chart project, I have three values and labels to display. When a user clicks on the chart, it should show the label of the clicked point. I am attempting to extract the values from the data points.

 $scope.data = ["prospective","CallBacks","Closed"];
        $scope.labels = ["4","2","3"];
$scope.onClick = function (points,evt) {
    console.log("Points: "+JSON.stringify(points));
  $scope.struct=JSON.stringify(points);
  $scope.value=$scope.struct.label;
    }
<canvas id="pieChart" class="chart chart-pie"
     chart-data="data" chart-labels="labels" chart-legend="true" chart-click="onClick">
   </canvas>
<span>{{value}}</span>

The log below shows the extracted Points:

[{"value":4,"outerRadius":95.5,"innerRadius":0,"fillColor":"rgba(151,187,205,0.8)","highlightColor":"rgba(151,187,205,0.8)","showStroke":true,"strokeWidth":2,"strokeColor":"#fff","startAngle":4.71238898038469,"circumference":1.9332877868244882,"label":"Prospective","_saved":{"value":4,"outerRadius":95.5,"innerRadius":0,"fillColor":"rgba(151,187,205,1)","highlightColor":"rgba(151,187,205,0.8)","showStroke":true,"strokeWidth":2,"strokeColor":"#fff","startAngle":4.71238898038469,"circumference":0,"label":"Prospective"},"endAngle":6.645676767209178}]

Although I can retrieve values from the log, when trying to use the same in $scope.value, the label appears as undefined.

Answer №1

Appreciate the assistance everyone! It appears that there was a series of JSON objects involved, but setting $scope.value=$scope.struct[0].label did the trick perfectly.

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

Modify the line to display as dashed when identified as a specific label in Chart.js

Currently, I am working on a project using Chart.js where I have implemented an area chart with multiple lines. My goal is to change the style of a line from solid to dashed based on a specific label. However, I am facing difficulties in modifying the bo ...

Retrieve the HTML content from the compiled template

function ($scope,$compile) { $scope.word="Habrahabra" var template = $compile("<p>{ { name } }</p>") var templ = template({name: "Ivan"}) document.getElementById("status").innerHTML =templ } I am currently facing an issue where in the ...

What could be causing this error with creating an order on Paypal?

Every time I run this code and click the Paypal button, I encounter the following error: Error: "TypeError: Cannot read property 'map' Do you have any clue why this is happening? I am pretty sure that I formatted it correctly. (I replaced MY_C ...

Avoid calling the inherited method multiple times in ES6 classes

Transitioning from RequireJS to browserify (along with babelify) has led me to rewrite my current modules as classes. Each of my RequireJS modules has a method named eventHandler that manages module-specific events. However, when extending a class, the sub ...

Modifying an AngularJS directive for the IIS Default Web Site: A step-by-step guide

Currently, I am in the process of developing a web application using ASP.NET MVC and AngularJS. When testing the application locally, the URL appears as follows: http://localhost/Home/Index#/Login However, once I deploy the application to the IIS develop ...

Determining the quantity of items within a div using jQuery

Similar Question: Retrieve the count of elements inside parent div using jQuery Can you determine the total number of elements within a specific div? <div id=count"> <span></span> <span></span> <span></ ...

I can't figure out why I'm receiving undefined even though all the variables are populated with the necessary

I have been working on a project that involves implementing email and password authentication using Firebase. However, I encountered an error when the user submits their credentials: FirebaseError: Firebase: Error (auth/admin-restricted-operation). at ...

Message via socket

I am facing an issue with my screen that receives notifications from the Spring Boot backend. I display these notifications in a bell icon. The problem arises when I delete a notification successfully, but upon receiving a new notification, the ones that ...

The React higher order component does not pass props to the HTML element

Looking for a way to add a custom background to any component simply by passing it through a function. This method works well with components created using React.createElement, but unfortunately does not work with standard HTML components. const Title = ...

Unexpected token error in TypeScript: Syntax mistake spotted in code

Being new to Angular, I understand that mastering TypeScript is crucial for becoming a skilled Angular developer. Therefore, I created this simple program: function loge(messag){ console.log(messag); } var message:string; message = "Hi"; loge(messa ...

Executing action in PHP script simultaneously with Ajax

My JavaScript skills are a bit rusty, and I need help adding a "delete" feature to some code that displays rows of data. The code includes PHP, jQuery, and other JS elements. Here's the snippet: <?php require_once '../../app/Mage.php'; M ...

Backend data not displaying on HTML page

I am currently working on an Angular 8 application where I have a service dedicated to fetching courses from an API endpoint. The service method that I'm using looks like this: loadCourseById(courseId: number) { return this.http.get<Cours ...

Tips for adjusting the size of a textarea to perfectly fit within a table cell

I have a textarea displayed within an input in a table, but I am looking to resize it so that it completely fills the table cell up to the borders. Here is the logic: <textarea type="textarea" value="{{data.directRowNo}}" id = " ...

Unlocking the Chrome performance tool summary using SeleniumDiscovering the Chrome performance tool

I'm looking to utilize the Chrome performance tool for analyzing my website and then extract a summary of the results using Selenium WebDriver in Java. Despite extensive searching, I haven't been able to find a suitable solution yet. To give you ...

How can I capture the submission form response from a "different domain"?

Currently, I am dealing with a unique situation where I need to submit a form and receive the response from the submission. This response will determine my next steps as I have to execute some additional logic based on it. The challenge in my case is that ...

Variations in the timing of image transitions

Currently, as a GCSE computing student, I am working on being able to modify the interval between different images in my code. Here's what I have so far... <!DOCTYPE html> <html> <body> <h1> Adjusting Traffic Light Changes & ...

Integrate ng-admin with ui-router for enhanced functionality

My AngularJS project (version 1.4.9) is built using ui-router and contains multiple states defined as follows: .state('overview', { url: '/overview', parent: 'dashboard', templateUrl: 'views/dashboard/overview.html ...

Is your WordPress one-page scroll JQuery script failing to function properly?

Currently attempting to develop a single page scroll feature. Within WordPress, my navigation contains anchor tags structured as follows: <a href="#contact">Contact</a> <a href="#about">About</a> The corresponding divs for the li ...

The challenge of having to manually refresh the browser each time an update is made using a put request in

When the user enters a name and number and clicks the add button, the new person's information is automatically added to the database. If the name already exists, a prompt will ask, 'name is already in the phonebook, do you want to update it with ...

What's the best way to display alert messages using the alert method in Node.js with Jade?

Is there a way to render a 'Jade view' with data? For example, in the following code: app.get('/', function(req, res){ res.render('alert', {msg: 'hi!'}); }); I attempted to write the Jade code below: (alert.ja ...