Chartjs-Angularjs line chart get data from sql

0👍

First you should aggregate your data returned from the database.Use the SUM() function.The correct format should be this:

Date       | Member 
-------------------
2016-06-23 | 5
2016-06-24 | 10

In the controller you should have an array.

data = [{Date:"2016-0-23",Member:5},{Date:"2016-06-24",Member:10}];

To create a simple chart you need the data and labels.

vm.labels = data.map(function (property) {return propery.Date;});
vm.data = data.map(function (property) {return propery.Member;});

On the HTML page:

<canvas id="line" class="chart chart-line" chart-data="vm.data" chart-labels="vm.labels"></canvas>

Leave a comment