AngularJS Simple Line Charts using JSON

AngularJS Simple Line Charts using JSON

In this Post We Will Explain About is AngularJS Simple Line Charts using JSON With Example and Demo.Welcome on infinityknow.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Simple line chart in angularjs with json dataExample

In this post we will show you Best way to implement Angularjs Column and Line Charts Example, hear for AngularJS MVC Dynamic Bar And Line Chart Using WEB APIwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

READ :  Best 5 track phone number and find the location free

Flot Basic Line Chart example – Pure Example – AngularJS

Include External Libs
[php]

Simple Angularchart Example Step By Steps

https://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.js
http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
http://code.highcharts.com/highcharts.js
http://chart.js
// your some scripts…..

[/php]

Include JavaScripts
[php]

function liveCtrl($scope, $http){
var chart-data = {“xData”: [“Jan”, “Feb”, “Mar”, “Apr”, “May”, “Jun”,”Jul”, “Aug”, “Sep”, “Oct”, “Nov”, “Dec”],”yData”:[{
“name”: “Laravel”,
“chart-data”: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}, {
“name”: “PHP”,
“chart-data”: [-0.2, 0.9, 5.7, 11.3, 19.0, 22.0, 24.9, 24.1, 20.1, 14.1, 9.6, 2.5]
}, {
“name”: “Angularjs”,
“chart-data”: [-0.9, 0.6, 3.5, 9.4, 13.5, 19.0, 18.6, 19.9, 14.3, 9.0, 3.9, 1.0]
}, {
“name”: “Vuejs”,
“chart-data”: [3.9, 4.2, 5.7, 9.5, 11.9, 15.2, 19.0, 16.6, 14.2, 10.3, 6.6, 4.9]
}]}

READ :  Basic Laravel 6 Eloquent Search Techniques

$scope.linechartsecondYData=chart-data.yData
$scope.linechartsecondXData=chart-data.xData
}

angular.module(‘LiveChartApp’,[‘LiveChart’], function( $routeProvider, $locationProvider ){
$routeProvider.when(‘/’,{
template: ”,
controller: liveCtrl
})
})

[/php]

chart.js
[php]
angular.module(‘LiveChart’, []).directive(‘chart’, function () {
return {
restrict:’E’,
template:’

‘,
transclude:true,
replace:true,
scope: ‘=’,
link:function (scope, element, param) {
console.log(‘oo’,param,scope[param.formatter])
var opt = {
chart:{
renderTo:element[0],
type:’line’,
marginRight:130,
marginBottom:40
},
title:{
text:param.title,
x:-20
},
subtitle:{
text:param.subtitle,
x:-20
},
xAxis:{
tickInterval:1,
title:{
text:param.xname
}
},
plotOptions:{
lineWidth:0.5
},
yAxis:{
title:{
text:param.yname
},
tickInterval:(param.yinterval)?new Number(param.yinterval):null,
max:param.ymax,
min: param.ymin
},
tooltip:{
formatter:scope[param.formatter]||function () {
return ‘‘ + this.y + ‘
}
},
legend:{
layout:’vertical’,
align:’right’,
verticalAlign:’top’,
x:-10,
y:100,
borderWidth:0
},
series:[
{
name:’Vuejs’,
chart-data:[7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6]
}
]
}

READ :  AngularJS Set Cookies Get Cookies ClearCookies

scope.$watch(function (scope) {
return JSON.stringify({
xAxis:{
categories:scope[param.xdata]
},
series:scope[param.ydata]
});
}, function (website) {
console.log(‘ola’)
website = JSON.parse(website)
if (!website.series)return;
angular.extend(opt,website)
var chart = new Highcharts.Chart(opt);
});
}
}

})
[/php]

Example

I hope you have Got What is Flot Basic Line Chart example – Pure Example – AngularJS And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.

Leave a Comment