Charts using ChartJS, Mongodb and Angular

1

Good evening, I have the following model:

    var mongoose = require('mongoose');
module.exports = function() {
    var schema = mongoose.Schema({
        nome: {
            type: String,
            required: true
        },
        valor: {
            type: Number,
            required: true
        }
return mongoose.model('Contato', schema);
};

I need to create a simple pie chart, showing Contact values.value values.

I imported the Chartjs into my html:

<script src="Chart.min.js"></script>

In my body, I tried to add the chart:

<div class="box-chart">

        <canvas id="GraficoPizza" style="width:100%;"></canvas>

        <script type="text/javascript">

            var options = {
                responsive:true
            };

            var data = [
                {
                    **value: Contato.valor(),**
                    **color:"#F7464A",**
                    **highlight: "#FF5A5E",**
                    **label: "Contato.nome"**
                },
            ]

            window.onload = function(){

                var ctx = document.getElementById("GraficoPizza").getContext("2d");
                var PizzaChart = new Chart(ctx).Pie(data, options);
            }  
        </script> 

My question is in the parameter passing of the variable data, I need a way to go through all the contacts, taking their value and generating a random color.

    
asked by anonymous 08.11.2017 / 00:06

0 answers