1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
| /**
| * Created by wisestone on 2018-11-05.
| */
| 'use strict';
|
| define(['app', 'googleChartLoader'],
| function (app, googleChartLoader) {
| app.directive('googleChart', ['$log', '$rootScope', '$resourceProvider', 'SweetAlert', '$filter',
| function ($log, $rootScope, $resourceProvider, SweetAlert, $filter) {
| return {
| restrict : 'E',
| scope : {
| columns : '=',
| rows : '=',
| options : '='
| },
| replace : true,
| templateUrl : '../custom_components/google-chart/google-chart.html',
| controller : function ($scope, $element, $attrs) {
|
|
|
| },
| link : function ($scope, $element, $attrs) {
| // 변수 모음
| $scope.vm = {
|
| };
|
| // 함수 모음
| $scope.fn = {
| drawChart : drawChart, // 차트 그리기
| init : init, // 차트 그리기
| };
|
| $scope.$on("drawChart", function (event, args){
| $scope.fn.init();
| });
|
| $scope.fn.init();
|
| function init() {
| google.charts.load('current', {'packages':['line']});
| google.charts.setOnLoadCallback(drawChart);
| }
|
| function drawChart() {
| var data = new google.visualization.DataTable();
| if ($scope.columns != null) {
| $scope.columns.forEach(function (column) {
| data.addColumn(column.id, column.name);
| })
| }
|
| // data.addColumn('number', '날짜');
| // data.addColumn('number', '홈페이지 변조 탐지');
| // data.addColumn('number', '경유지 탐지');
| // data.addColumn('number', '일감 조회');
| if ($scope.rows != null) {
| data.addRows($scope.rows);
| // $scope.rows.forEach(function (row) {
| // data.addRow(row);
| // });
| }
|
| // data.addRows([
| // [1, 37.8, 80.8, 41.8],
| // [2, 30.9, 69.5, 32.4],
| // [3, 25.4, 57, 25.7],
| // [4, 11.7, 18.8, 10.5],
| // [5, 11.9, 17.6, 10.4],
| // [6, 8.8, 13.6, 7.7],
| // [7, 7.6, 12.3, 9.6],
| // [8, 12.3, 29.2, 10.6],
| // [9, 16.9, 42.9, 14.8],
| // [10, 12.8, 30.9, 11.6],
| // [11, 5.3, 7.9, 4.7],
| // [12, 6.6, 8.4, 5.2],
| // [13, 4.8, 6.3, 3.6],
| // [14, 4.2, 6.2, 3.4]
| // ]);
|
| // var options = {
| // chart: {
| // title: '일감 유형별 API 사용 현황',
| // subtitle: '최근 15일'
| // },
| // width: 900,
| // height: 500
| // };
|
| var chart = new google.charts.Line(document.getElementById('chart'));
|
| chart.draw(data, google.charts.Line.convertOptions($scope.options));
| }
| }
| };
| }])
| });
|
|