annotate modules/web_view/graph.html @ 21:f730dd0bcf85

dynamic checking of the tile-status
author sean
date Thu, 13 Aug 2015 12:17:46 +0200
parents f89ad628f831
children 05e5441c5160
rev   line source
16
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
1 <style type = text/css>
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
2
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
3 * {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
4 font-family: "Sans-serif";
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
5 font-size: 14px;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
6 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
7
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
8 .svg div{
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
9 font: 10px;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
10 text-align: right;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
11 float: left;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
12 display: block;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
13 padding: 10px;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
14 margin: 10px;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
15 color: white;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
16 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
17
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
18 .axis path,
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
19
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
20 .axis line {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
21 fill: none;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
22 stroke: lightgrey;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
23 /*opacity: 0.7;*/
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
24 stroke-width: 1px;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
25 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
26
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
27 .y.axis path {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
28 display: none;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
29 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
30
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
31 .line {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
32 fill: none;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
33 stroke-width: 3px;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
34 opacity: 1;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
35 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
36
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
37 .line.critical {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
38 stroke: red;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
39 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
40
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
41 .line.critical.legend {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
42 fill: red;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
43 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
44
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
45 .line.urgent {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
46 stroke: orange;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
47 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
48
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
49 .line.urgent.legend {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
50 fill: orange;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
51 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
52
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
53 .line.bug {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
54 stroke: violet;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
55 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
56
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
57 .line.bug.legend {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
58 fill: violet;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
59 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
60
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
61 .line.feature {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
62 stroke: chartreuse;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
63 style: stroke-dasharray;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
64 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
65
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
66 .line.feature.legend {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
67 fill: chartreuse;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
68 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
69
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
70 .line.wish {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
71 stroke: blue;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
72 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
73
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
74 .line.wish.legend {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
75 fill: blue;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
76 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
77
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
78 .grid .tick {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
79 stroke: lightgrey;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
80 /*opacity: 0.7;*/
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
81 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
82
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
83 .grid path {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
84 stroke-width: 0;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
85 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
86
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
87 </style>
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
88
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
89 <!-- <div id="content" style="display: inline-block"></div> -->
21
f730dd0bcf85 dynamic checking of the tile-status
sean
parents: 16
diff changeset
90 <!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js" charset="utf-8"></script> -->
f730dd0bcf85 dynamic checking of the tile-status
sean
parents: 16
diff changeset
91
f730dd0bcf85 dynamic checking of the tile-status
sean
parents: 16
diff changeset
92 <script type="text/javascript" src="static/d3.v3.min.js"></script>
f730dd0bcf85 dynamic checking of the tile-status
sean
parents: 16
diff changeset
93
16
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
94 <script type="text/javascript">
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
95
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
96 // window.onresize = function(){
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
97 // document.getElementsByClassName("chart")[0].innerHTML = "";
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
98 // makeChart();
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
99 // };
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
100
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
101 var d3jsInjectionTarget="X";
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
102
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
103 var critical=[];
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
104 var urgent=[];
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
105 var bug=[];
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
106 var feature=[];
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
107 var wish=[];
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
108 var timestamp=[];
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
109
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
110 // var critical=[
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
111 // {points: 4},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
112 // {points: 12},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
113 // {points: 8},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
114 // {points: 2}
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
115 // ]
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
116 //
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
117 // var urgent=[
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
118 // {points: 3},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
119 // {points: 24},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
120 // {points: 17},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
121 // {points: 19}
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
122 // ]
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
123 //
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
124 // var bug=[
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
125 // {points: 10},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
126 // {points: 2},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
127 // {points: 2},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
128 // {points: 12}
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
129 // ]
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
130 //
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
131 // var feature=[
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
132 // {points: 4},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
133 // {points: 21},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
134 // {points: 12},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
135 // {points: 4}
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
136 // ]
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
137 //
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
138 // var wish=[
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
139 // {points: 22},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
140 // {points: 18},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
141 // {points: 32},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
142 // {points: 10}
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
143 // ]
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
144 //
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
145 //
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
146 // var timestamp=[
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
147 // {date : new Date('2015-06-30T12:36:47')},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
148 // {date : new Date('2015-07-01T12:37:26')},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
149 // {date : new Date('2015-07-02T12:38:26')},
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
150 // {date : new Date('2015-07-03T12:39:26')}
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
151 // ]
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
152
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
153 document.addEventListener("DOMContentLoaded", function(event) {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
154 makeChart();
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
155 });
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
156
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
157 function assignIssueToDate(issueArray, dateArray){
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
158 a = [];
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
159 for (var i = 0; i < issueArray.length; i++) {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
160 a.push({points: issueArray[i].points, date : dateArray[i].date});
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
161 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
162
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
163 return a;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
164 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
165
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
166 function limitDatesOnXAxis(limit){
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
167 if (timestamp.length < limit){
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
168 return timestamp.length;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
169 } else {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
170 return limit;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
171 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
172 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
173
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
174 function maxInObject( array ){
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
175 var maxVal = 0;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
176 for (var i = 0; i < array.length; i++) {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
177 if (maxVal < array[i].points){
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
178 maxVal = array[i].points;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
179 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
180 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
181 return maxVal;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
182 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
183
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
184
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
185 function getMaxIssues(){
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
186 maxIssuesOfAllArrays = [];
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
187 maxIssuesOfAllArrays.push(maxInObject(critical));
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
188 maxIssuesOfAllArrays.push(maxInObject(urgent));
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
189 maxIssuesOfAllArrays.push(maxInObject(bug));
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
190 maxIssuesOfAllArrays.push(maxInObject(feature));
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
191 maxIssuesOfAllArrays.push(maxInObject(wish));
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
192
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
193 return Math.max.apply(Math, maxIssuesOfAllArrays)+1;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
194 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
195
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
196
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
197 function dayDifference(first, second) {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
198 "use strict";
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
199 var difference = (second - first) / (1000 * 60 * 60 * 24);
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
200
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
201 // just to avoid the get thousands of lines... would look ugly.
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
202 if (difference > 60){
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
203 difference = 60;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
204 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
205
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
206 return difference;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
207 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
208
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
209
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
210 // function for the grid lines
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
211 function makeGrid(direction, orientation, ticknumber) {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
212 return d3.svg.axis()
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
213 .scale(direction)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
214 .orient(orientation)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
215 .ticks( ticknumber );
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
216 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
217
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
218
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
219 //append a svg_path. pretty generic
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
220 function draw_line(svg, data_array, css_class, line_object, lineShape){
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
221 svg.append("path")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
222 .datum(assignIssueToDate(data_array, timestamp))
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
223 .attr("class", css_class)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
224 .style("stroke-dasharray", (lineShape))
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
225 .attr("d", line_object);
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
226 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
227
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
228
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
229 function makeLegend(svg, width){
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
230
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
231 var legend_distance = width+40;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
232 var top_distance = 20;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
233 var distance_steps = 50;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
234
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
235
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
236 function set_propper_distance(steps){
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
237 top_distance += steps;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
238 return top_distance;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
239 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
240
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
241 function draw_legend_line(svg, width, Ypos, text, issues){
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
242 svg.append("svg:text")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
243 .attr("class", "legend")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
244 .attr("x", width-30 )
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
245 .attr("y", Ypos)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
246 .text(text + ":");
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
247
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
248 svg.append("svg:text")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
249 .attr("class", "legend")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
250 .attr("x", width+35 )
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
251 .attr("y", Ypos)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
252 .text(issues);
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
253
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
254 svg.append("rect")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
255 .attr("class", "line " + text.toLowerCase() + " legend")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
256 .attr("x", width-30)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
257 .attr("y", Ypos-20)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
258 .attr("width", 100)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
259 .attr("height", 2);
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
260 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
261
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
262 draw_legend_line(svg, legend_distance, set_propper_distance(distance_steps), "Critical", critical[critical.length-1].points);
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
263 draw_legend_line(svg, legend_distance, set_propper_distance(distance_steps), "Urgent", urgent[urgent.length-1].points);
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
264 draw_legend_line(svg, legend_distance, set_propper_distance(distance_steps), "Bug", bug[bug.length-1].points);
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
265 draw_legend_line(svg, legend_distance, set_propper_distance(distance_steps), "Feature", feature[feature.length-1].points);
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
266 draw_legend_line(svg, legend_distance, set_propper_distance(distance_steps), "Wish", wish[wish.length-1].points);
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
267 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
268
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
269
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
270
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
271 //draw the chart
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
272 function makeChart(div_name){
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
273
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
274 //declaration
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
275 var sizeOfSystemBorders = 20;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
276 // var margin = {top: 20, right: 100, bottom: 90, left: 60};
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
277 // var margin = {top: 0, right: 0, bottom: 0, left: 0}
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
278
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
279 var width = document.getElementsByClassName("chart")[0].clientWidth;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
280 var height = document.getElementsByClassName("chart")[0].clientHeight;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
281 // var width = (document.documentElement.clientWidth-sizeOfSystemBorders) - margin.left - margin.right;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
282 // var height = (document.documentElement.clientHeight-sizeOfSystemBorders) - margin.top - margin.bottom;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
283
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
284 var x = d3.time.scale()
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
285 .range([0, width]);
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
286
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
287 var y = d3.scale.linear()
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
288 .range([height, 0]);
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
289
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
290 var base_line = d3.svg.line()
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
291 .x(function(d) { return x(d.date); })
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
292 .y(function(d) { return y(d.points); });
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
293
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
294 //lines
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
295 var criticalLine = base_line;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
296 var urgentLine = base_line;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
297 var bugLine = base_line;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
298 var featureLine = base_line;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
299 var wishLine = base_line;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
300 var timestampLine = base_line;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
301
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
302
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
303 //set domain of y axis
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
304 var yDomain = [ ];
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
305 yDomain[0] = 0;
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
306 yDomain[1] = getMaxIssues();
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
307 y.domain(d3.extent(yDomain, function(d){return d; }));
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
308
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
309 //set domain of y axis
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
310 x.domain(d3.extent(timestamp, function(d){return d.date; }));
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
311
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
312
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
313 var xAxis = d3.svg.axis()
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
314 .scale(x)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
315 .orient("bottom")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
316 .ticks(limitDatesOnXAxis(10))
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
317 .tickFormat(d3.time.format("%d.%m"));
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
318 // .tickFormat(d3.time.format("%d.%m:%H:%M"));
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
319 // .tickFormat(d3.time.format("%X"));
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
320 // .tickFormat(d3.time.format.iso);
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
321
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
322
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
323 var yAxis = d3.svg.axis()
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
324 .scale(y)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
325 .orient("left");
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
326
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
327
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
328 var svg = d3.select("." + d3jsInjectionTarget)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
329 .append("svg")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
330 .attr("class", "svg")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
331 // .attr("width", width)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
332 // .attr("height", height)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
333 .attr("width", width-20)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
334 .attr("height", height-10)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
335 .append("g")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
336 // .attr("transform", "translate( +50,+0,+0,+0)");
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
337 .attr("transform", "translate(40 , 0)");
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
338
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
339
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
340 // creation
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
341
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
342
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
343 // Draw the x Grid lines
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
344 // svg.append("g")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
345 // .attr("class", "grid")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
346 // .attr("transform", "translate(0," + height + ")")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
347 // .call(makeGrid(x, "bottom", timestamp.length)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
348 // .tickSize(-height, 0, 0)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
349 // .tickFormat("")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
350 // );
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
351
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
352
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
353 // Draw the y Grid lines
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
354 svg.append("g")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
355 .attr("class", "grid")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
356 .call(makeGrid(y, "left", function(){return Math.min(getMaxIssues(), 10);}())
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
357 .tickSize(-width, 0, 0)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
358 .tickFormat("")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
359 );
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
360
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
361
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
362 // Draw the x-axis
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
363 svg.append("g")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
364 .attr("class", "x axis")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
365 // .attr("transform", "translate(0, " + 20-height + ")")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
366 .call(xAxis)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
367 .selectAll("text")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
368 .style("text-anchor", "end")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
369 // .attr("dx", "-.5em")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
370 // .attr("dy", ".1em")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
371 // .attr("transform", function() {
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
372 // return "rotate(-30)";
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
373 // });
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
374
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
375
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
376 // Draw the y-axis
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
377 svg.append("g")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
378 .attr("class", "y axis")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
379 .call(yAxis)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
380 .append("text")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
381 .attr("transform", "rotate(-90)")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
382 .attr("y", 6)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
383 .attr("dy", ".71em")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
384 .style("text-anchor", "end");
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
385
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
386
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
387 // Text for y-axis
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
388 // svg.append("text")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
389 // .attr("transform", "rotate(-90)")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
390 // .attr("y", 10 - margin.left)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
391 // .attr("x", 0 - (height / 2))
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
392 // .attr("dy", "1em")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
393 // .style("text-anchor", "middle")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
394 // .text("Issues");
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
395
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
396
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
397 //Titel und Legende
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
398 // svg.append("svg:text")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
399 // .attr("class", "text")
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
400 // .attr("x", 10)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
401 // .attr("y", -5)
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
402 // .text("Issues Nach Zeit");
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
403
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
404 draw_line(svg, wish, "line wish", wishLine, "0, 0");
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
405 draw_line(svg, feature, "line feature", featureLine, "3, 3");
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
406 draw_line(svg, bug, "line bug", bugLine, "7, 7");
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
407 draw_line(svg, urgent, "line urgent", urgentLine, "13, 13");
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
408 draw_line(svg, critical, "line critical", criticalLine, "17, 17");
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
409
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
410
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
411 // makeLegend(svg, width);
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
412 }
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
413
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
414
f89ad628f831 adding the renamed files
sean
parents:
diff changeset
415 </script>
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)