annotate modules/roundup_cc/graph.html @ 12:50f4c64834cb

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