quickstart-svg.html
2.6 KB
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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<head>
<object id="AdobeSVG" width="1" height="1" classid="clsid:78156a80-c6a1-4bbf-8e6a-3cd390eeb4e2"></object>
<?import namespace="svg" implementation="#AdobeSVG"?>
<title>PlotKit: Quickstart SVG Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="/css/page.css" media="screen" rel="Stylesheet"
type="text/css" />
<link href="tests.css" media="screen" rel="Stylesheet" type="text/css" />
<script src="/js/mochi/MochiKit.js" type="text/javascript"></script>
<script src="/js/plotkit-svn/excanvas.js" type="text/javascript"></script>
<script src="/js/plotkit-svn/PlotKit_Packed.js" type="text/javascript"></script>
</head>
<body>
<div id="body">
<h2>Quickstart SVG Demo</h2>
<div style="margin: 0 auto 0 auto; width: 500px;">
<div id="svgcontainer" style="width: 500px; height:300px;"></div>
<br/>
<table id="values" class="data">
<thead>
<tr><td>x</td><td>y1</td><td>y2</td></tr>
</thead>
<tbody>
<tr><td>0</td><td>0</td><td>3</td></tr>
<tr><td>1</td><td>10</td><td>20</td></tr>
<tr><td>2</td><td>5</td><td>10</td></tr>
<tr><td>3</td><td>6</td><td>7</td></tr>
<tr><td>4</td><td>7</td><td>8</td></tr>
<tr><td>5</td><td>6</td><td>7</td></tr>
<tr><td>6</td><td>7</td><td>8</td></tr>
</tbody>
</table>
<p><em>Note: With SVG, the most compatible way is NOT to put in SVG tags, but create the SVG element with Javascript. Therefore, instead of adding <svg> tag, we just have a <div> container and create the SVG element using SVGRenderer.SVG().</em></p>
<script type="text/javascript">
var layout = new Layout("line");
layout.addDatasetFromTable("dataset2", $("values"), xcol = 0, ycol = 2);
layout.addDatasetFromTable("dataset1", $("values"), xcol = 0, ycol = 1);
layout.evaluate();
var svg = SVGRenderer.SVG({"width": 500, "height": 300, "id":"chart"});
$('svgcontainer').appendChild(svg);
var chart = new SweetSVGRenderer(svg, layout);
chart.render();
</script>
</div>
<div class="footer"><a href="http://www.liquidx.net/plotkit/">PlotKit</a></div>
</div>
</body></html>