-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
115 lines (105 loc) · 3.29 KB
/
index.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
<html style="margin: 0; width: 100%; height: 100%; ">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<title>Testing and Development</title>
<body style="margin: 0px; width: 100%; height: 100%;">
<div id="dev" style="width:inherit; height:inherit; margin:0; overflow:hidden;">
<div id="container" style="width: inherit; height: inherit;">
<div id="diagram1-container">
<svg id="my-svg1" version="1.1" baseProfile="full" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" width="100%" height="250" style="display:inline" preserveAspectRatio="xMidYMid">
<g>
<desc>Demo for cross-platform-shapes library.</desc>
</g>
<title>diagram</title>
<g class="viewport">
<rect fill="yellow" x="50" y="200" width="100" height="20"></rect>
<rect fill="green" x="160" y="200" width="100" height="20" transform="rotate(45,210,210)"></rect>
</g>
</svg>
<canvas id="my-canvas" width="150" height="150"></canvas>
</div>
<div id="diagram2-container">
</div>
</div>
</div>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="./dist/lib/cross-platform-text/js/cross-platform-text.js"></script>
<script>
// TODO look at window.onLoad
window.onload = function() {
var crossPlatformTextInstance1 = crossPlatformText.getInstance({
targetSelector:'#my-svg1'
});
var text1 = crossPlatformTextInstance1.render({
id:'my-text1',
x:50,
y:200,
width:100,
height:20,
containerSelector:'g.viewport',
textContent:'My text 1',
textAlign:'center',
verticalAlign:'middle',
color:'blue',
fontSize:12
});
var text2 = crossPlatformTextInstance1.render({
id:'my-text2',
x:160,
y:200,
width:100,
height:20,
containerSelector:'g.viewport',
textContent:'My text 2',
textAlign:'center',
verticalAlign:'middle',
color:'orange',
fontSize:12,
rotation:45
});
var crossPlatformTextInstance2 = crossPlatformText.getInstance({
targetSelector:'#diagram2-container',
format: 'svg'
});
var text3 = crossPlatformTextInstance2.render({
id:'my-text3',
x:50,
y:200,
width:100,
height:20,
containerSelector:'g.viewport',
textContent:'My text 3',
textAlign:'center',
verticalAlign:'middle',
color:'blue',
fontSize:12
});
var text4 = crossPlatformTextInstance1.render({
id:'my-text4',
x:150,
y:20,
width:100,
height:20,
containerSelector:'g.viewport',
textContent:'My text 4\nwith two lines',
textAlign:'center',
verticalAlign:'middle',
color:'blue',
fontSize:12
});
var text5 = crossPlatformTextInstance2.render({
id:'my-text5',
x:160,
y:200,
width:100,
height:20,
containerSelector:'g.viewport',
textContent:'My text 5',
textAlign:'center',
verticalAlign:'middle',
color:'red',
fontSize:12,
rotation:20
});
};
</script>