Closed lingarajkolaui closed 6 years ago
var myapp = angular.module('myapp', ["highcharts-ng"]); myapp.controller('myctrl', ['$scope', '$http', '$timeout', '$interval', '$window', '$document', function(s, h, t, i, w, d) { s.reftime = 600; var comptime = []; var klps = []; var ss = "2017"; var ss1 = "09",ss2 = "19" ,ss3 = "08" ,ss4 = "31"; s.chp = ''; s.klps = ''; s.saveData = function(chdata, pointinterval, comptime) { s.chp = s.comptime.substr(0, s.comptime.indexOf(' ')).split("-"); //2017-09-19 19:58 s.klps = s.comptime.substr(s.comptime.indexOf(' ') + 1).split(":"); s.chdata = chdata; s.pointerval = pointinterval; s.comptime = comptime; ss = s.chp[0],ss1 = s.chp[1],ss2 = s.chp[2],ss3 = s.klps[0],ss4 = s.klps[1]; //s.myss = Date.UTC(s.chp[0], s.chp[1], s.chp[2], s.klps[0], s.klps[1]) s.chartConfig.series = s.chdata; //s.myss = Date.UTC(s.chp[0], s.chp[1], s.chp[2], s.klps[0], s.klps[1]) s.datutc = Date.UTC(ss,ss1,ss2,ss3,ss4); console.log(s.datutc) return s; } s.jsonUrl = 'js/realtime_users.json'; s.chdata = []; s.getData = function() { h.get(s.jsonUrl).then(function(response) { s.userdata = response.data; console.log(s.userdata) angular.forEach(s.userdata[domainoption], function(value, key) { s.comptime = value.time[0]; s.pointerval = value.time[0]; s.chdata.push({ name: value.name, data: value.data }) }); //console.log(s.chdata + '-----------------------' + s.comptime); s.saveData(s.chdata, s.pointerval, s.comptime) }); } s.getData(); //var chpoint = s.comptime; //var chp = chpp.substr(0,chpp.indexOf(' ')).split("-"); //var klps = chpp.substr(chpp.indexOf(' ')+1).split(":"); s.chartConfig = { option:{ chart: { height: 500, width: 1100, type: 'line' } }, title: { text: '' }, subtitle: { enabled: false, text: '', align: 'left' }, xAxis: { type: 'datetime' }, yAxis: { title: { text: 'Number of Users' } }, plotOptions: { series: { events: { legendItemClick: function(event) { } }, pointStart: console.log(s.datutc), pointInterval: (1 * 3600 * 1000) / 60 } }, series: s.chdata, title: { text: 'Hello' } } s.reflow = function() { s.$broadcast('highchartsng.reflow'); };