comparison rhodecode/public/js/graph.js @ 2921:582224526c23 beta

graph: remove unused stuff, simplify
author Aras Pranckevicius <aras@unity3d.com>
date Mon, 15 Oct 2012 15:42:03 +0300
parents e2b6bc77619a
children 1f3ae3690756
comparison
equal deleted inserted replaced
2920:8464d0e96e97 2921:582224526c23
33 this.ctx.fillStyle = 'rgb(0, 0, 0)'; 33 this.ctx.fillStyle = 'rgb(0, 0, 0)';
34 this.cur = [0, 0]; 34 this.cur = [0, 0];
35 this.max_column = 1; 35 this.max_column = 1;
36 this.line_width = 2.5; 36 this.line_width = 2.5;
37 this.dot_radius = 5.5; 37 this.dot_radius = 5.5;
38 this.bg = [0, 4];
39 this.cell = [2, 0];
40 this.revlink = '';
41 38
42 this.scale = function(height) { 39 this.scale = function(height) {
43 this.box_size = Math.floor(height/1.2); 40 this.box_size = Math.floor(height/1.2);
44 this.cell_height = this.box_size;
45 this.bg_height = height;
46 } 41 }
47 42
48 this.setColor = function(color, bg, fg) { 43 this.setColor = function(color, bg, fg) {
49 color %= colors.length; 44 color %= colors.length;
50 var red = (colors[color][0] * fg) || bg; 45 var red = (colors[color][0] * fg) || bg;
56 var s = 'rgb(' + red + ', ' + green + ', ' + blue + ')'; 51 var s = 'rgb(' + red + ', ' + green + ', ' + blue + ')';
57 this.ctx.strokeStyle = s; 52 this.ctx.strokeStyle = s;
58 this.ctx.fillStyle = s; 53 this.ctx.fillStyle = s;
59 } 54 }
60 55
61 this.render = function(data,pad) { 56 this.render = function(data,width) {
62 var idx = 1; 57 var idx = 1;
63 var rela = document.getElementById('graph'); 58 var rela = document.getElementById('graph');
64 var pad = pad; 59 var pad = width;
65 var scale = 22; 60 var scale = 22;
66 61
67 for (var i in data) { 62 for (var i in data) {
68 this.scale(scale); 63 this.scale(scale);
69 64
70 var row = document.getElementById("chg_"+idx); 65 var row = document.getElementById("chg_"+idx);
71 if (row == null) 66 if (row == null)
72 continue; 67 continue;
73 var next = document.getElementById("chg_"+(idx+1)); 68 var next = document.getElementById("chg_"+(idx+1));
74 var extra = 0; 69 var extra = 0;
75
76 this.cell[1] += row.clientWidth;
77 this.bg[1] += this.bg_height;
78 70
79 cur = data[i]; 71 cur = data[i];
80 nodeid = cur[0]; 72 nodeid = cur[0];
81 node = cur[1]; 73 node = cur[1];
82 in_l = cur[2]; 74 in_l = cur[2];
100 } 92 }
101 93
102 this.setColor(color, 0.0, 0.65); 94 this.setColor(color, 0.0, 0.65);
103 95
104 96
105 x = pad-((this.cell[0] + this.box_size * start - 1) + this.bg_height-2); 97 x = pad-(this.box_size * start - 1 + scale);
106 98
107 this.ctx.lineWidth=this.line_width; 99 this.ctx.lineWidth=this.line_width;
108 this.ctx.beginPath(); 100 this.ctx.beginPath();
109 this.ctx.moveTo(x, rowY); 101 this.ctx.moveTo(x, rowY);
110 102
111 103
112 if (start == end) 104 if (start == end)
113 { 105 {
114 x = pad-((1 + this.box_size * end) + this.bg_height-2); 106 x = pad-((1 + this.box_size * end) + scale-2);
115 this.ctx.lineTo(x,nextY+extra,3); 107 this.ctx.lineTo(x,nextY+extra,3);
116 } 108 }
117 else 109 else
118 { 110 {
119 var x2 = pad-((1 + this.box_size * end) + this.bg_height-2); 111 var x2 = pad-((1 + this.box_size * end) + scale-2);
120 var ymid = (rowY+nextY) / 2; 112 var ymid = (rowY+nextY) / 2;
121 this.ctx.bezierCurveTo (x,ymid,x2,ymid,x2,nextY); 113 this.ctx.bezierCurveTo (x,ymid,x2,ymid,x2,nextY);
122 } 114 }
123 this.ctx.stroke(); 115 this.ctx.stroke();
124 } 116 }
126 column = node[0] 118 column = node[0]
127 color = node[1] 119 color = node[1]
128 120
129 radius = this.dot_radius; 121 radius = this.dot_radius;
130 122
131 x = pad-(Math.round(this.cell[0] * scale/2 * column + radius) + 15 - (column*4)); 123 x = pad-(Math.round(scale * column + radius) + 15 - (column*4));
132 124
133 this.ctx.beginPath(); 125 this.ctx.beginPath();
134 this.setColor(color, 0.25, 0.75); 126 this.setColor(color, 0.25, 0.75);
135 this.ctx.arc(x, rowY, radius, 0, Math.PI * 2, true); 127 this.ctx.arc(x, rowY, radius, 0, Math.PI * 2, true);
136 this.ctx.fill(); 128 this.ctx.fill();