Skip to content

Commit a1ce332

Browse files
committed
rudimentary graphinng working. next add logic to separate products
1 parent 7f4072c commit a1ce332

2 files changed

Lines changed: 94 additions & 34 deletions

File tree

learning_web_proj/angularLearning/app/controllers/reportConfigController.js

Lines changed: 88 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ var cntrlFunction = function ($scope, $routeParams, $location, runReportFactory)
110110
console.log("running the report");
111111
startDate = $scope.startDate.getStringDate();
112112
endDate = $scope.endDate.getStringDate();
113-
reportResolution = $scope.reportResolution.selected
113+
reportResolution = $scope.reportResolution.selected;
114114
console.log("start date is: " + startDate);
115115
console.log("end date is:" + endDate);
116116

117-
utcStart = $scope.startDate.getUTCDate()
118-
utcEnd = $scope.endDate.getUTCDate()
117+
utcStart = $scope.startDate.getUTCDate();
118+
utcEnd = $scope.endDate.getUTCDate();
119119
console.log('utcStart' + utcStart);
120120
console.log('utcEnd' + utcEnd);
121121
$scope.showprogress = true;
@@ -126,40 +126,95 @@ var cntrlFunction = function ($scope, $routeParams, $location, runReportFactory)
126126
{'startDate': utcStart,
127127
'endDate': utcEnd,
128128
'reportResolution': reportResolution}, function() {
129-
var i, j, row;
130-
// $scope.reportData array of objects!
131-
// [ {0: <date>, 1:<number>}]
132-
133-
134-
135-
for ( i=0; i<$scope.reportData.length; i+=1) {
136-
vals = '';
137-
keys = Object.keys($scope.reportData[i])
138-
for ( j=0; j<keys.length; j++) {
139-
vals = vals + ' - ' + $scope.reportData[i][j]
140-
}
141-
142-
console.log("vals: " + vals);
143-
144-
console.log("keys " + keys )
145-
}
146-
console.log('report data: ' + $scope.reportData);
129+
var i, j, row, chartData;
130+
chartData = restructData($scope.reportData);
131+
$scope.chartObject = chartData;
132+
console.log('chartObject');
133+
console.log(JSON.stringify(chartData));
134+
$scope.showprogress = false;
147135
});
148-
149-
// $scope.reportData = runReportFactory.query({'startDate': utcStart,
150-
// 'endDate': utcEnd,
151-
// 'reportResolution': reportResolution});
152-
//
153-
136+
154137
};
155138

139+
function restructData(inData) {
140+
var cnt, retData, i, keys, j, dataTabCols, dataTabVals;
141+
dataTabCols = [];
142+
dataTabVals = [];
143+
console.log("indata is:" + inData);
144+
// deal with the columns
145+
for (i=0; i<inData.length; i+=1) {
146+
keys = Object.keys(inData[i]);
147+
148+
//console.log("keys: " + keys )
149+
//for (j=keys.length-1; j>=0; j-=1) {
150+
for (j=0; j<keys.length; j+=1) {
151+
colRow = {};
152+
console.log(keys[j] + " : " + inData[i][keys[j]]);
153+
colRow.id = [keys[j]];
154+
colRow.label = [keys[j]];
155+
if (keys[j] === 'sample_time') {
156+
colRow.type = 'string';
157+
} else if (keys[j] === 'lic_used'){
158+
colRow.type = 'number';
159+
}
160+
else {
161+
console.log('888888888888888888888888888888888888888');
162+
}
163+
console.log("---------------------")
164+
console.log("id: " + colRow.id);
165+
console.log("label: " + colRow.label);
166+
console.log("type is " + colRow.type);
167+
168+
dataTabCols.push(colRow);
169+
}
170+
break;
171+
}
172+
173+
// now deal with row data
174+
for (i=0; i<inData.length; i+=1) {
175+
keys = Object.keys(inData[i]);
176+
rowData = {};
177+
rowData.c = [];
178+
console.log("new row of data");
179+
//console.log("keys: " + keys )
180+
//for (j=keys.length-1; j>=0; j-=1) {
181+
for (j=0; j<keys.length; j+=1) {
182+
value = {};
183+
value.v = inData[i][keys[j]];
184+
console.log(" " + keys[j] + ' : ' + value.v + ' (' + typeof value.v + ') ');
185+
rowData.c.push(value);
186+
}
187+
dataTabVals.push(rowData);
188+
}
189+
190+
191+
// stuff to figure out how to dynamically configure later on
192+
retData = {};
193+
retData.type = "LineChart";
194+
retData.displayed = true;
195+
retData.title = 'graph chart title';
196+
retData.data = {cols:dataTabCols, rows:dataTabVals};
197+
retData.options = {
198+
title: 'my first chart',
199+
isStacked: true,
200+
fill: 20,
201+
displayExactValues: true,
202+
vAxis: {
203+
title: 'vaxis Title',
204+
gridlines: {
205+
count: 10
206+
}
207+
},
208+
hAxis: {
209+
title: 'horizontal Title'
210+
}
211+
};
212+
retData.formatters = {};
213+
return retData;
214+
}
215+
156216
function showChart() {
157-
$scope.chart = {
158-
type: 'LineChart',
159-
displayed: true,
160-
data: '',
161-
rows:
162-
}
217+
$scope.chart = '';
163218
}
164219

165220
// $scope.open = function() {

learning_web_proj/angularLearning/app/partials/reportConfig.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,15 @@ <h5>
7171
</div>
7272
<div id='report'>
7373
<div class='row'>
74-
<div class='col-xs-6' align='right'>
74+
<div class='col-xs-10' align='center'>
7575
<progressbar animate='true' class="progress-striped active" value="progressbarState" ng-show='showprogress' type="progressBarType">{{progressMessage}} </progressbar>
7676
</div>
7777
</div>
78+
<div class='row'>
79+
<div class='col-xs-10' align='center'>
80+
<div google-chart chart='chartObject' style='{{cssStyle}}'></div>
81+
</div>
82+
</div>
7883
</div>
7984
<!-- <div class='row'>
8085
<div class='col-xs-8' align='center'>

0 commit comments

Comments
 (0)