1 appDS2.controller('reportChartController', function ($scope, $rootScope, $timeout, $window, $http, $routeParams,modalService) {
3 //alert($scope.chartType.value);
4 console.log("reportChartController called");
5 $scope.commonOptionOpen = false;
6 $scope.additionalOptionOpen = false;
8 $scope.selectedChartType = {value:""};
9 $scope.chartTypeOptions = [
10 {value: 'barChart', text: 'Bar Chart'},
11 {value: 'timeSeries', text: 'Time Series/Area Chart'},
12 {value: 'pieChart', text: 'Pie Chart'},
13 {value: 'annotationChart', text: 'Annotation Chart'},
14 {value: 'flexibleTimeChart', text: 'Flexible Time Chart'}
17 $scope.animateSelected = {value:false};
19 $scope.populateChrtWzdFields = function() {
20 $scope.reportRunJson = {};
21 $http.get("raptor.htm?action=chart.json&c_master="+$routeParams.reportId).then(function (response) {
22 $scope.reportRunJson = response.data;
24 if ($scope.reportRunJson.chartTypeJSON) {
25 var chrtTypeValue = $scope.reportRunJson.chartTypeJSON.value;
26 for(var i = 0; i < $scope.chartTypes.length; i++) {
27 var obj = $scope.chartTypes[i];
28 //console.log(obj.id);
29 if ($scope.chartTypes[i].value==chrtTypeValue) {
30 $scope.reportRunJson.chartTypeJSON.index=$scope.chartTypes[i].index;
31 $scope.reportRunJson.chartTypeJSON.title=$scope.chartTypes[i].title;
38 if ($scope.reportRunJson.domainAxisJSON) {
39 var domaninAxisValue = $scope.reportRunJson.domainAxisJSON.value;
40 for(var i = 0; i < $scope.reportRunJson.chartColumnJSONList.length; i++) {
41 if ($scope.reportRunJson.chartColumnJSONList[i].value==domaninAxisValue) {
42 $scope.reportRunJson.domainAxisJSON.index=$scope.reportRunJson.chartColumnJSONList[i].index;
43 $scope.reportRunJson.domainAxisJSON.title=$scope.reportRunJson.chartColumnJSONList[i].title;
50 if ($scope.reportRunJson.categoryAxisJSON) {
51 var categoryAxisValue = $scope.reportRunJson.categoryAxisJSON.value;
52 for(var i = 0; i < $scope.reportRunJson.chartColumnJSONList.length; i++) {
53 if ($scope.reportRunJson.chartColumnJSONList[i].value==categoryAxisValue) {
54 $scope.reportRunJson.categoryAxisJSON.index=$scope.reportRunJson.chartColumnJSONList[i].index;
55 $scope.reportRunJson.categoryAxisJSON.title=$scope.reportRunJson.chartColumnJSONList[i].title;
60 //Set range axis label
61 if ($scope.reportRunJson.rangeAxisList) {
62 for(var j = 0; j < $scope.reportRunJson.rangeAxisList.length; j++) {
64 if ($scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON) {
65 var rangeAxisLabelValue = $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON.value;
66 for(var i = 0; i < $scope.reportRunJson.chartColumnJSONList.length; i++) {
67 if ($scope.reportRunJson.chartColumnJSONList[i].value==rangeAxisLabelValue) {
68 $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON.index=$scope.reportRunJson.chartColumnJSONList[i].index;
69 $scope.reportRunJson.rangeAxisList[j].rangeAxisLabelJSON.title=$scope.reportRunJson.chartColumnJSONList[i].title;
78 if ($scope.reportRunJson.rangeAxisList) {
79 for(var j = 0; j < $scope.reportRunJson.rangeAxisList.length; j++) {
80 if ($scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON != null && $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.value != ""
81 && $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.value != null) {
82 var lineTypeValue = $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.value;
83 for(var i = 0; i < $scope.lineTypes.length; i++) {
84 if ($scope.lineTypes[i].value==lineTypeValue) {
85 $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.index=$scope.lineTypes[i].index;
86 $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON.title=$scope.lineTypes[i].title;
90 $scope.reportRunJson.rangeAxisList[j].rangeLineTypeJSON = null;
95 if ($scope.reportRunJson.rangeAxisList) {
96 for(var j = 0; j < $scope.reportRunJson.rangeAxisList.length; j++) {
97 if ($scope.reportRunJson.rangeAxisList[j].rangeColorJSON != null && $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.value != ""
98 && $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.value != null) {
99 var colorValue = $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.value;
100 for(var i = 0; i < $scope.rangeColors.length; i++) {
101 if ($scope.rangeColors[i].value==colorValue) {
102 $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.index=$scope.rangeColors[i].index;
103 $scope.reportRunJson.rangeAxisList[j].rangeColorJSON.title=$scope.rangeColors[i].title;
107 $scope.reportRunJson.rangeAxisList[j].rangeColorJSON = null;
113 $scope.legend = "true";
116 $scope.saveChartData = function() {
117 //Converting string variables to numbers
118 $scope.reportRunJson.commonChartOptions.rightMargin = Number($scope.reportRunJson.commonChartOptions.rightMargin);
119 $scope.reportRunJson.commonChartOptions.topMargin = Number($scope.reportRunJson.commonChartOptions.topMargin);
120 $scope.reportRunJson.commonChartOptions.bottomMargin = Number($scope.reportRunJson.commonChartOptions.bottomMargin);
121 $scope.reportRunJson.commonChartOptions.leftMargin = Number($scope.reportRunJson.commonChartOptions.leftMargin);
123 if ($scope.reportRunJson.categoryAxisJSON == "") {
124 console.log('Inside categoryAxisJSON value');
125 $scope.reportRunJson.categoryAxisJSON = {};
126 $scope.reportRunJson.categoryAxisJSON.value = -1;
127 console.log('$scope.reportRunJson.categoryAxisJSON',$scope.reportRunJson.categoryAxisJSON);
130 console.log($scope.reportRunJson);
131 $http.post("save_chart", JSON.stringify($scope.reportRunJson)).success(function(data, status) {
132 $scope.successSubmit=true;
137 $scope.addRangeAxisRow = function (rangeaxisitem) {
138 $scope.reportRunJson.rangeAxisList.push({
142 $scope.removeRangeAxisRow = function (index) {
143 $scope.reportRunJson.rangeAxisList.splice(index, 1);
147 $scope.init = function () {
149 $scope.populateChrtWzdFields();
155 $scope.domainItems = [{title:"Domain Axis1", content:"Test1", open: false},{title:"Domain Axis2", content:"Test2", open: false}];
157 $scope.chartTypes = [
158 {index: 0, value: 'BarChart3D', title: 'Bar Chart'},
159 {index: 1, value: 'TimeSeriesChart', title: 'Time Series/Area Chart'},
160 {index: 2, value: 'PieChart', title: 'Pie Chart'},
161 {index: 3, value: 'AnnotationChart', title: 'Annotation Chart'},
162 {index: 4, value: 'FlexTimeChart', title: 'Flexible Time Chart'}
165 $scope.categories = [
166 {index: 0, value: 'scenario_name', title: 'scenario_name'},
167 {index: 1, value: 'total_traffic_in_PB', title: 'Total Traffic in PB'},
168 {index: 2, value: 'Avg Utilization Day', title: 'Avg Utilization Day'}
171 $scope.rangeColors = [
172 {index: 0, value: "#1f77b4",title: "Dodger Blue"},
173 {index: 1, value: "#ff7f0e",title: "Vivid orange"},
174 {index: 2, value: "#2ca02c",title: "Forest Green"},
175 {index: 3, value: "#8c864b",title: "Greenish Red"},
176 {index: 4, value: "#9467bd",title: "Desaturated violet"},
177 {index: 5, value: "#8c564b",title: "Dark moderate red"},
178 {index: 6, value: "#e377c2",title: "Soft pink"},
179 {index: 7, value: "#7f7f7f",title: "Dark gray"},
180 {index: 8, value: "#bcbd22",title: "Strong yellow"},
181 {index: 9, value: "#17becf",title: "Strong cyan"},
182 {index: 10, value: "#dc143c",title: "Vivid red"},
183 {index: 11, value: "#800080",title: "Dark magenta"},
184 {index: 12, value: "#0000FF",title: "Blue"},
185 {index: 13, value: "#008000",title: "Dark lime green"},
186 {index: 14, value: "#D2691E",title: "Reddish Orange"},
187 {index: 15, value: "#FF0000",title: "Red"},
188 {index: 16, value: "#000000",title: "Black"},
189 {index: 17, value: "#DB7093",title: "Pink"},
190 {index: 18, value: "#FF00FF",title: "Pure Magenta"},
191 {index: 19, value: "#7B68EE",title: "Soft blue"},
192 {index: 20, value: "#1f77b6",title: "Strong blue"},
193 {index: 21, value: "#9edae5",title: "Very soft cyan"},
194 {index: 22, value: "#393b79",title: "Dark Blue"},
195 {index: 23, value: "#5254a3",title: "Dark moderate Blue"},
196 {index: 24, value: "#6b6ecf",title: "Slightly desaturated blue"},
197 {index: 25, value: "#9c9ede",title: "Very soft blue"},
198 {index: 26, value: "#637939",title: "Dark Green"},
199 {index: 27, value: "#8ca252",title: "Dark moderate green"},
200 {index: 28, value: "#b5cf6b",title: "Slightly desaturated green"},
201 {index: 29, value: "#cedb9c",title: "Desaturated Green"},
204 {index: 30, value: "#00FFFF",title: "Aqua"},
205 {index: 31, value: "#000000",title: "Black"},
206 {index: 32, value: "#0000FF",title: "Blue"},
207 {index: 33, value: "#FF00FF",title: "Fuchsia"},
208 {index: 34, value: "#808080",title: "Gray"},
209 {index: 35, value: "#008000",title: "Green"},
210 {index: 36, value: "#00FF00",title: "Lime"},
211 {index: 37, value: "#800000",title: "Maroon"},
212 {index: 38, value: "#000080",title: "Navy"},
213 {index: 39, value: "#808000",title: "Olive"},
214 {index: 40, value: "#FF9900",title: "Orange"},
215 {index: 41, value: "#800080",title: "Purple"},
216 {index: 42, value: "#FF0000",title: "Red"},
217 {index: 43, value: "#C0C0C0",title: "Silver"},
218 {index: 44, value: "#008080",title: "Teal"},
219 {index: 45, value: "#FFFFFF",title: "White"},
220 {index: 46, value: "#FFFF00",title: "Yellow"}
225 {index: 0, value: 'default', title: 'Default'},
226 {index: 1, value: 'dotted_lines', title: 'Dotted Lines'},
227 {index: 2, value: 'dashed_lines', title: 'Dashed Lines'}
230 $scope.hardCodeReport= {
232 "reportName":"Test: Line Chart",
238 "chartColumnJSONList":[
242 "title":"traffic_date",
252 "formfield_comments":null,
254 "chartSqlWhole":"SELECT traffic_date tr0, traffic_date tr0_1,util_perc ut1, 1 FROM portal.demo_util_chart ORDER BY 1",
255 "chartAvailable":true,
256 "chartType":{"index": "", "value": "Bar Chart", "title": ""},
261 "staggerLabels":false,
266 "title":"traffic_date",
277 "hasCategoryAxis":false,
289 "value":"dotted_lines",
295 "title":"traffic_date",
310 "value":"dashed_lines",
319 "title":"traffic_date",
329 "primaryAxisLabel":"testlabel",
330 "secondaryAxisLabel":"testseclabel",
339 var colorValue = $scope.hardCodeReport.rangeAxisList[0].rangeColor.value;
341 $timeout(function() {
342 $rootScope.isViewRendering = false;
348 app.directive('onlyDigits', function () {
353 link: function (scope, element, attrs, ngModel) {
354 if (!ngModel) return;
355 ngModel.$parsers.unshift(function (inputValue) {
356 var digits = inputValue.split('').filter(function (s) { return (!isNaN(s) && s != ' '); }).join('');
357 ngModel.$viewValue = digits;
365 app.directive('onlyCharacters', function () {
369 link: function (scope, element, attrs, ngModel) {
370 if (!ngModel) return;
371 ngModel.$parsers.unshift(function (inputValue) {
372 var digits = inputValue.split('').filter(function (s) { return (isNaN(s) && s != ' '); }).join('');
373 ngModel.$viewValue = digits;