-
Notifications
You must be signed in to change notification settings - Fork 4
/
Line_Chart_After_Draw.html
150 lines (131 loc) · 6.31 KB
/
Line_Chart_After_Draw.html
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<!DOCTYPE html>
<html lang="en" ng-app="MyApp">
<head>
<meta charset="UTF-8">
<title>Anychart AngularJS plugin demo.</title>
<script src="../node_modules/angular/angular.min.js"></script>
<script src="../node_modules/anychart/dist/js/anychart-base.min.js"></script>
<script src="../node_modules/anychart/dist/js/anychart-ui.min.js"></script>
<script src="../node_modules/anychart/dist/js/anychart-exports.min.js"></script>
<script src="../dist/anychart-angularjs.min.js"></script>
<link rel="stylesheet" href="../node_modules/anychart/dist/css/anychart-ui.min.css">
<link rel="stylesheet" href="../node_modules/anychart/dist/fonts/css/anychart-font.min.css">
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
</style>
<script>
(function() {
'use strict';
function afterDrawProcessor(chart) {
chart.padding([10, 180, 5, 20]);
chart.title().padding([0, 0, 5, 0]);
chart.yScale().minimum(20).maximum(65);
// tune y scale
chart.yScale().ticks().set([20, 28, 38, 48, 65]);
// change yAxis title text settings
chart.yAxis().title('DTI');
// format y axis labels
chart.yAxis().labels().format("{%Value}%");
// create extra y axis on the right
// primary Y Scale setup earlier is used by default
// setting it up explictly look like this: chart.yAxis(1).scale(chart.yScale());
chart.yAxis(1).orientation('right').enabled(true);
chart.yAxis(1).labels().format("{%Value}%");
// create range axes markers
chart.rangeMarker().from(20).to(28).fill('#4db6ac 0.4');
chart.rangeMarker(1).from(28).to(38).fill('#80cbc4 0.4');
chart.rangeMarker(2).from(38).to(48).fill('#b2dfdb 0.4');
chart.rangeMarker(3).from(38).to(65).fill('#e0f2f1 0.4');
// create text axes markers
chart.textMarker()
.value(24)
.fontColor('#263238')
.align('right')
.anchor('leftcenter')
.offsetX(10)
.useHtml(true)
.text('<strong>Below 28%</strong><br/>Buy! Buy! Buy!');
chart.textMarker(1)
.value(33)
.fontColor('#263238')
.align('right')
.anchor('leftcenter')
.offsetX(10)
.useHtml(true)
.text('<strong>28%-38%</strong><br/>Marginally affordable with<br/>fixed-rate mortgages.');
chart.textMarker(2)
.value(43)
.fontColor('#263238')
.align('right')
.anchor('leftcenter')
.offsetX(10)
.useHtml(true)
.text('<strong>38%-48%</strong><br/>Purchase is not affordable<br/>with fixed-rate mortgage.');
chart.textMarker(3)
.value(56)
.align('right')
.fontColor('#263238')
.anchor('leftcenter')
.offsetX(10)
.useHtml(true)
.text('<strong>48% or greater</strong><br/>Not affordable with fixed<br/>or interest only.<br/>Negative amortization<br/>only option.');
chart.legend().fontSize(13).padding([0, 0, 15, 0]);
}
angular
.module('MyApp', ['anychart-angularjs'])
.controller('MyCtrl', ['$scope', function($scope) {
var dataSet = anychart.data.set([
['1986', 41, 36, 31],
['1987', 37, 34, 29],
['1988', 48, 47, 40],
['1989', 53, 52, 45],
['1990', 49, 49, 42],
['1991', 49, 47, 40],
['1992', 41, 39, 33],
['1993', 39, 36, 31],
['1994', 34, 31, 27],
['1995', 38, 35, 30],
['1996', 29, 28, 24],
['1997', 33, 32, 27],
['1998', 31, 33, 28],
['1999', 31, 32, 28],
['2000', 37, 40, 34],
['2001', 35, 40, 34],
['2002', 43, 48, 41],
['2003', 43, 47, 40],
['2004', 51, 47, 40],
['2005', 56, 50, 43],
['2006', 62, 56, 48]
]);
var chart = anychart.line();
var seriesData_1 = dataSet.mapAs({x: [0], value: [1]});
var seriesData_2 = dataSet.mapAs({x: [0], value: [2]});
var seriesData_3 = dataSet.mapAs({x: [0], value: [3]});
// create 3 line series and tune them using chaining calls
chart.line(seriesData_1).name('Beechum County').hovered().markers().enabled(true).type('circle').size(4);
chart.line(seriesData_2).name('Greenbow County').hovered().markers().enabled(true).type('circle').size(4);
chart.line(seriesData_3).name('Belle Reve Parish').hovered().markers().enabled(true).type('circle').size(4);
//Notify plugin about we use a custom instance of chart.
$scope.ch = chart;
//Add after draw processor for chart instance.
$scope.afterDraw = afterDrawProcessor;
}]);
})();
</script>
</head>
<body ng-controller="MyCtrl">
<div
anychart
ac-title="Debt-To-Income Ratios 1986-2006"
ac-legend="true"
style="width: 100%; height: 100%"
ac-instance="ch"
ac-chart-draw="afterDraw">
</div>
</body>
</html>