简体   繁体   中英

Implement chart.js in Angularjs

I am creating project using angularjs. In my project i am implementing the charts using chart.js library.I have problem while implementing the charts.In normal javascript charts are working fine,but in angular I got problem in some point.

I normal javascript:

 var lineChartData = {
            labels :[1,4,8,6,8],
            datasets : [
                {
                   data : arr
                }] 
var ctx = document.getElementById("canvas").getContext("2d");
        window.myLine = new Chart(ctx).Line(lineChartData, {
        }); 
 console.log(window.myLine) // 

working fine in normal javascript, window.myLine but I want this in angularjs

In AngularJs:

 $scope.chartLinkData = {
                            labels: mapTimeForward,
                            data: [mapValueForward, mapValueReverse]
                        };

Here is plunker which is in normal javascript,but I want this in angular

https://plnkr.co/edit/CDWhpNP2KNB4ZZjuFFYM?p=preview

Currently I am using charts from:

http://jtblin.github.io/angular-chart.js/

But here is not given inner detail

There is a very nice angular module built on top of chart.js. To use chart.js in an angular app you can use angular-chart.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM