-
Notifications
You must be signed in to change notification settings - Fork 0
/
svgspeedcharttest.aspx
69 lines (65 loc) · 2.68 KB
/
svgspeedcharttest.aspx
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
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="svgspeedcharttest.aspx.cs" Inherits="test" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>svg performance test</title>
<script>
var source = new EventSource("data.ashx");
source.onmessage = function (e) {
update(JSON.parse(e.data));
}
function update(data) {
var lab = document.getElementById('label');
var svg = document.getElementById('svg');
var w = svg.clientWidth || svg.parentNode.clientWidth;
var h = svg.clientHeight || svg.parentNode.clientHeight;
for (var line = 0; line < 9; line++) {
var polyline = document.getElementById('polyline' + (line + 1));
var pts = polyline.points;
var maxlength = 5000;
var addpertime = data.length;
var excess = pts.length + addpertime - maxlength;
while (excess-- > 0) {
pts.removeItem(0);
}
for (var i = 0; i < addpertime; i++) {
var point = svg.createSVGPoint();
point.x = 1;
var y = data[i].y1;
if (line == 1) { y = data[i].y2; }
else if (line == 2) { y = data[i].y3; }
else if (line == 3) { y = data[i].y4; }
else if (line == 4) { y = data[i].y5; }
else if (line == 5) { y = data[i].y6; }
else if (line == 6) { y = data[i].y7; }
else if (line == 7) { y = data[i].y8; }
else if (line == 8) { y = data[i].y9; }
point.y = ((line) / 10 + 0.1 * y) * h;
pts.appendItem(point);
}
for (var i = 0; i < pts.length; i++) {
pts[i].x = w * i / (pts.length - 1);
}
lab.textContent = "Points loaded: " + pts.length;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<b id="label"></b>
<br />
<svg id="svg" width="1000" height="600" style="width:1000px; height:600px; border: 1px solid #000000;">
<polyline id="polyline1" points="" style="fill: none; stroke: black; stroke-width: 1" />
<polyline id="polyline2" points="" style="fill: none; stroke: red; stroke-width: 1" />
<polyline id="polyline3" points="" style="fill: none; stroke: green; stroke-width: 1" />
<polyline id="polyline4" points="" style="fill: none; stroke: blue; stroke-width: 1" />
<polyline id="polyline5" points="" style="fill: none; stroke: yellow; stroke-width: 1" />
<polyline id="polyline6" points="" style="fill: none; stroke: darkred; stroke-width: 1" />
<polyline id="polyline7" points="" style="fill: none; stroke: pink; stroke-width: 1" />
<polyline id="polyline8" points="" style="fill: none; stroke: lightpink; stroke-width: 1" />
<polyline id="polyline9" points="" style="fill: none; stroke: gray; stroke-width: 1" />
</svg>
</form>
</body>
</html>