modify angular graph

0

My friends are trying to solve a problem that I have been looking for solution on some forums and none specifically help me.

I have a graph using piechart that renders a pie chart. But it works with fixed values, but I have a return from the bank and I mount a json, the question is how do I put all json values in the 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 the one below

{"dados":[
      {"y":1,"key":"REQUISICAO"},
      {"y":1,"key":"SITEF"},
      {"y":1,"key":"NetSms"},
      {"y":2,"key":"CA"}
]}
    
asked by anonymous 14.05.2018 / 19:12

0 answers