##// END OF EJS Templates
hgweb: create Graph methods using a prototype...
av6 -
r35255:9c99541e default
parent child Browse files
Show More
@@ -33,21 +33,24 b' function Graph() {'
33 this.cell = [2, 0];
33 this.cell = [2, 0];
34 this.columns = 0;
34 this.columns = 0;
35
35
36 this.reset = function() {
36 }
37
38 Graph.prototype = {
39 reset: function() {
37 this.bg = [0, 4];
40 this.bg = [0, 4];
38 this.cell = [2, 0];
41 this.cell = [2, 0];
39 this.columns = 0;
42 this.columns = 0;
40 document.getElementById('nodebgs').innerHTML = '';
43 document.getElementById('nodebgs').innerHTML = '';
41 document.getElementById('graphnodes').innerHTML = '';
44 document.getElementById('graphnodes').innerHTML = '';
42 };
45 },
43
46
44 this.scale = function(height) {
47 scale: function(height) {
45 this.bg_height = height;
48 this.bg_height = height;
46 this.box_size = Math.floor(this.bg_height / 1.2);
49 this.box_size = Math.floor(this.bg_height / 1.2);
47 this.cell_height = this.box_size;
50 this.cell_height = this.box_size;
48 };
51 },
49
52
50 this.setColor = function(color, bg, fg) {
53 setColor: function(color, bg, fg) {
51
54
52 // Set the colour.
55 // Set the colour.
53 //
56 //
@@ -75,9 +78,9 b' function Graph() {'
75 this.ctx.fillStyle = s;
78 this.ctx.fillStyle = s;
76 return s;
79 return s;
77
80
78 };
81 },
79
82
80 this.edge = function(x0, y0, x1, y1, color, width) {
83 edge: function(x0, y0, x1, y1, color, width) {
81
84
82 this.setColor(color, 0.0, 0.65);
85 this.setColor(color, 0.0, 0.65);
83 if(width >= 0)
86 if(width >= 0)
@@ -87,9 +90,9 b' function Graph() {'
87 this.ctx.lineTo(x1, y1);
90 this.ctx.lineTo(x1, y1);
88 this.ctx.stroke();
91 this.ctx.stroke();
89
92
90 };
93 },
91
94
92 this.render = function(data) {
95 render: function(data) {
93
96
94 var backgrounds = '';
97 var backgrounds = '';
95 var nodedata = '';
98 var nodedata = '';
@@ -155,9 +158,9 b' function Graph() {'
155 document.getElementById('nodebgs').innerHTML += backgrounds;
158 document.getElementById('nodebgs').innerHTML += backgrounds;
156 document.getElementById('graphnodes').innerHTML += nodedata;
159 document.getElementById('graphnodes').innerHTML += nodedata;
157
160
158 };
161 }
159
162
160 }
163 };
161
164
162
165
163 function process_dates(parentSelector){
166 function process_dates(parentSelector){
General Comments 0
You need to be logged in to leave comments. Login now