-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
chart_axis.html
156 lines (125 loc) · 7.09 KB
/
chart_axis.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
151
152
153
154
155
156
<!-- ############################################################################################################################## -->
<!-- # John Wiley & Sons, Inc. # -->
<!-- # # -->
<!-- # Book: Algorithms in Bioinformatics: Theory and Implementation # -->
<!-- # Author: Dr. Paul A. Gagniuc # -->
<!-- # # -->
<!-- # Institution: # -->
<!-- # University Politehnica of Bucharest # -->
<!-- # Faculty of Engineering in Foreign Languages # -->
<!-- # Department of Engineering in Foreign Languages # -->
<!-- # # -->
<!-- # Area: European Union # -->
<!-- # Date: 04/01/2021 # -->
<!-- # # -->
<!-- # Mode: Native JavaScript # -->
<!-- # # -->
<!-- # Cite this work as: # -->
<!-- # Paul A. Gagniuc. Algorithms in Bioinformatics: Theory and Implementation. John Wiley & Sons, 2021, ISBN: 9781119697961. # -->
<!-- # # -->
<!-- ############################################################################################################################## -->
<canvas id="bio" height="300" width="1100"></canvas>
<script>
var A = "0,2.62,5.23,7.82,10.4,12.94,15.45,17.92,20.34,22.7,25,27.23,29.39,31.47,33.46,35.36,37.16,38.86,40.45,41.93,43.3,44.55,45.68,46.68,47.55,48.3,48.91,49.38,49.73,49.93,50,49.93,49.73,49.38,48.91,48.3,47.55,46.68,45.68,44.55,43.3,41.93,40.45,38.86,37.16,35.36,33.46,31.47,29.39,27.23,25,22.7,20.34,17.92,15.45,12.94,10.4,7.82,5.23,2.62,0,-2.62,-5.23,-7.82,-10.4,-12.94,-15.45,-17.92,-20.34,-22.7,-25,-27.23,-29.39,-31.47,-33.46,-35.36,-37.16,-38.86,-40.45,-41.93,-43.3,-44.55,-45.68,-46.68,-47.55,-48.3,-48.91,-49.38,-49.73,-49.93,-50,-49.93,-49.73,-49.38,-48.91,-48.3,-47.55,-46.68,-45.68,-44.55,-43.3,-41.93,-40.45,-38.86,-37.16,-35.36,-33.46,-31.47,-29.39,-27.23,-25,-22.7,-20.34,-17.92,-15.45,-12.94,-10.4,-7.82,-5.23,-2.62,0";
var B = "1,-0.99,0.96,-0.91,0.84,-0.76,0.66,-0.55,0.42,-0.29,0.15,-0.01,-0.13,0.27,-0.4,0.53,-0.64,0.74,-0.83,0.9,-0.95,0.99,-1,0.99,-0.97,0.92,-0.86,0.78,-0.68,0.57,-0.45,0.32,-0.18,0.04,0.1,-0.24,0.38,-0.5,0.62,-0.72,0.81,-0.89,0.94,-0.98,1,-1,0.97,-0.93,0.87,-0.79,0.7,-0.59,0.47,-0.34,0.21,-0.07,-0.08,0.22,-0.35,0.48,-0.6,0.71,-0.8,0.88,-0.93,0.98,-1,1,-0.98,0.94,-0.88,0.81,-0.72,0.61,-0.49,0.37,-0.23,0.09,0.05,-0.19,0.33,-0.46,0.58,-0.69,0.78,-0.86,0.93,-0.97,0.99,-1,0.98,-0.95,0.9,-0.82,0.74,-0.63,0.52,-0.39,0.26,-0.12,-0.02,0.16,-0.3,0.43,-0.56,0.67,-0.77,0.85,-0.91,0.96,-0.99,1,-0.99,0.96,-0.91,0.84,-0.75,0.65,-0.54,0.42,-0.28";
var C = "0,-0.14,-0.29,-0.45,-0.64,-0.86,-1.14,-1.53,-2.13,-3.27,-6.41,-75.31,7.75,3.61,2.29,1.62,1.2,0.9,0.67,0.48,0.32,0.17,0.03,-0.12,-0.26,-0.42,-0.6,-0.81,-1.08,-1.44,-2,-2.99,-5.45,-25.09,9.79,4.03,2.47,1.72,1.27,0.95,0.71,0.52,0.35,0.2,0.05,-0.09,-0.23,-0.39,-0.56,-0.77,-1.02,-1.36,-1.87,-2.74,-4.74,-15.04,13.27,4.54,2.67,1.83,1.34";
Chart(A, '#ff0000', 'y');
Chart(B, '#0055ff', 'n');
Chart(C, '#000000', 'n');
function Chart(q,c,e) {
var s = q.split(",");
var mx = Math.max.apply(null, s);
var mn = Math.min.apply(null, s);
var canvas = document.getElementById('bio');
var w = canvas.width;
var h = canvas.height;
if (canvas.getContext) {
var ctx = canvas.getContext('2d');
if(e=='y'){ctx.clearRect(0, 0, w, h);}
ctx.moveTo(0, 0);
ctx.beginPath();
var d = ((w-80)/s.length);
for (var i=0; i<=s.length-1; i++)
{
var y = h - 15 - (((h-15) / (mx-mn)) * (s[i]-mn));
var x = d * i;
ctx.lineTo(x, y+1);
}
ctx.lineWidth = 2;
ctx.strokeStyle = c;
ctx.stroke();
if(s.length>=2 && s.length<=(w-80) && e=='y'){
ctx.closePath();
ctx.beginPath();
//horisontal divisions
ctx.strokeStyle = '#454545';
//distance between divisions must be visible
if((w/s.length)>=5){
for (var i=0; i<s.length; i++)
{
ctx.moveTo(Math.floor(d*i), h-10);
ctx.lineTo(Math.floor(d*i), h);
}
ctx.stroke();
}
//bottom line
ctx.moveTo(0, h-1);
ctx.lineTo(w-80, h-1);
ctx.stroke();
//left vertical line
ctx.moveTo((w-80), 0);
ctx.lineTo((w-80), h);
ctx.stroke();
//top axis
ctx.moveTo((w-80), 1);
ctx.lineTo((w-50), 1);
ctx.stroke();
//top left vertical line
ctx.moveTo((w-55), 0);
ctx.lineTo((w-55), 14);
ctx.stroke();
//bottom axis
ctx.moveTo((w-80), h-15);
ctx.lineTo((w-70), h-15);
ctx.stroke();
//vertical divisions
for (var i=0; i<10; i++)
{
ctx.moveTo(w-80, ((h-15)/10)*i);
ctx.lineTo(w-70, ((h-15)/10)*i);
}
ctx.stroke();
//MAX value on chart
text = mx;
dim = ctx.measureText(text).width
ctx.save();
ctx.translate((w-80)+18,18);
ctx.rotate(Math.PI / 2);
ctx.font = "18px Arial";
ctx.fillStyle = "#000000";
ctx.textAlign = "left";
ctx.fillText(text, 0, 0);
ctx.restore();
//MAX text
text = 'MAX';
dim = ctx.measureText(text).width
ctx.save();
ctx.translate((w-65)+20,14);
ctx.font = "18px Arial";
ctx.fillStyle = "#000000";
ctx.textAlign = "left";
ctx.fillText(text, 0, 0);
ctx.restore();
text = mn;
dim = ctx.measureText(text).width
ctx.save();
ctx.translate((w-80)+20,h-10);
ctx.font = "18px Arial";
ctx.fillStyle = "#000000";
ctx.textAlign = "left";
ctx.fillText(text, 0, 0);
ctx.restore();
}
}
}
</script>