[Chartjs]-ChartJS with AngularJS – Canvas won't display anything

5👍

Someone else on my hack team figured it out later that day.
Here is the HTML:

<article class="col-xs-6 col-md-offset-3 col-md-6 center">
    <canvas id="expenses" width="200" height="100"></canvas>
        <script>
                    var pieData = [
            {
                    value: 20,
                    color:"#878BB6"
            },
            {
                    value : 40,
                    color : "#4ACAB4"
            },
            {
                    value : 10,
                    color : "#FF8153"
            },
            {
                    value : 30,
                    color : "#FFEA88"
            }
    ];
    var pieOptions = {
            segmentShowStroke : false,
            animateScale : true
    }
    var expenses = document.getElementById("expenses").getContext("2d");
    new Chart(expenses).Pie(pieData, pieOptions);
    </script>

</article>

For more, our github repo (the view was the “cashflow.html” one) and to see how it rendered.

Probably not the best way to do it.

1👍

It looks like your missing ng-app in your HTML which would contain which angular app you will be using.

You can put it in the inside one of the divs wrapping the graph.

Leave a comment