modify angular chart

Asked

Viewed 40 times

0

friends I am trying to solve a problem which I have been looking for solution in some forums and none helps me specifically.

I have a chart using piechart that renders a pie chart. However it uses fixed values, only I get a return from the bank and mount a json, the question is how do I put all values of json in piechart? if I use an array it returns only the last value. Someone could help me.

var app = angular.module('plunker', ['nvd3']);

app.controller('MainCtrl', function ($scope) {
    $scope.options = {
        chart: {
            type: 'pieChart',
            height: 500,
            x: function (d) {
                return d.key;
            },
            y: function (d) {
                return d.y;
            },
            showLabels: true,
            duration: 500,
            labelThreshold: 0.01,
            labelSunbeamLayout: true,
            legend: {
                margin: {
                    top: 5,
                    right: 35,
                    bottom: 5,
                    left: 0
                }
            }
        }
    };


    $scope.sistemas = [
        {
            key: results.dados[0].key,
            y: results.dados[0].y
        }
    ];


});

the Json code that returns is this below

{"dados":[
      {"y":1,"key":"REQUISICAO"},
      {"y":1,"key":"SITEF"},
      {"y":1,"key":"NetSms"},
      {"y":2,"key":"CA"}
]}
  • Which chart library do you use?

  • Chart.js Piectrl of angular

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.