-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDirectiveCol.js
82 lines (76 loc) · 2.5 KB
/
DirectiveCol.js
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
var weBTrading = angular.module('weBTrading.col', []);
weBTrading.directive('colchart', ['$timeout', function ($timeout)
{
return {
restrict: 'E',
template: "<div><div id='{{colId}}' class='colChart'></div></div>",
replace: true,
scope:
{
colchartdata: "=",
colId: "@",
accessor: "="
},
link: function (scope, element, attrs)
{
$timeout(function ($scope, $element, $attrs)
{
var arrFieldsNames = []
for (currField in scope.colchartdata[0])
{
if (scope.colchartdata[0].hasOwnProperty(currField))
{
arrFieldsNames.push(currField);
}
}
var colChart = AmCharts.makeChart(scope.colId,
{
"type": "serial",
"theme": "chalk",
"dataProvider": scope.colchartdata,
"valueAxes":
[{
"gridColor": "#FFFFFF",
"gridAlpha": 0.2,
"dashLength": 0
}],
"gridAboveGraphs": true,
"startDuration": 1,
"graphs":
[{
"balloonText": "[[category]]: <b>[[value]]</b>",
"fillAlphas": 0.8,
"lineAlpha": 0.2,
"type": "column",
"valueField": arrFieldsNames[1]
}],
"chartCursor":
{
"categoryBalloonEnabled": false,
"cursorAlpha": 0,
"zoomable": false
},
"categoryField": arrFieldsNames[0],
"categoryAxis":
{
"gridPosition": "start",
"gridAlpha": 0,
"tickPosition": "start",
fontSize: 15,
autoWrap: true,
"tickLength": 20
},
"export":
{
"enabled": true
}
});
scope.accessor.refreshCol = function ()
{
colChart.dataProvider = scope.colchartdata;
colChart.validateData();
};
});
}
};
}]);