-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
142 lines (122 loc) · 4.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
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
<html>
<head>
<meta charset="utf-8">
<!-- anychart -->
<!--<script src="../node_modules/anychart/dist/js/anychart-bundle.min.js"></script>-->
<script src="https://cdn.anychart.com/releases/v8/js/anychart-bundle.min.js"></script>
<!-- anychart themes -->
<script src="https://cdn.anychart.com/releases/v8/themes/dark_blue.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/themes/dark_earth.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/themes/dark_glamour.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/themes/dark_provence.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/themes/dark_turquoise.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/themes/light_blue.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/themes/light_earth.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/themes/light_glamour.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/themes/light_provence.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/themes/light_turquoise.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/themes/coffee.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/themes/monochrome.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/themes/morning.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/themes/pastel.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/themes/sea.min.js"></script>
<script src="https://cdn.anychart.com/releases/v8/themes/wines.min.js"></script>
<!-- anychart css -->
<link href="https://cdn.anychart.com/releases/v8/css/anychart-ui.min.css" type="text/css" rel="stylesheet">
<link href="https://cdn.anychart.com/releases/v8/fonts/css/anychart-font.min.css" type="text/css" rel="stylesheet">
<!--cloudflare cdn-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.3.15/proj4.js"></script>
<!-- anychart chart editor -->
<link href="dist/anychart-editor.min.css" type="text/css" rel="stylesheet">
<script src="dist/anychart-editor.min.js"></script>
<style>
html, body {
padding: 0;
margin: 0;
}
#helper {
width: 100%;
height: 100%;
}
#editor-container {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
#container-wrapper {
position: absolute;
left: 10%;
right: 10%;
top: 10%;
bottom: 10%;
}
#container {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 56px;
}
#restart {
position: absolute;
bottom: 0;
left: 0;
border-radius: 4px;
font-size: 16px;
padding: 10px 16px;
display: inline-block;
cursor: pointer;
background: #549de1;
border: none;
color: white;
}
</style>
</head>
<body>
<div id="helper"></div>
<div id="editor-container"></div>
<div id="container-wrapper">
<div id="container"></div>
<button id="restart" onclick="startEditor();">Build New Chart</button>
</div>
<script>
var editor = null;
var chart = null;
function startEditor() {
// dispose chart
if (chart) {
chart.dispose();
chart = null;
}
// run chart editor
editor = anychart.editor();
editor.render(document.getElementById('editor-container'));
editor.listen('editorComplete', function () {
var code = editor.getJavascript();
buildChart(code);
});
// hide restart button
document.getElementById('restart').style.display = 'none';
}
function buildChart(code) {
// dispose editor
if (editor) {
editor.dispose();
editor = null;
}
// build chart
chart = eval(code);
// show restart btn
// hide restart button
document.getElementById('restart').style.display = 'inline-block';
}
</script>
<script>
anychart.onDocumentReady(function () {
startEditor();
});
</script>
</body>
</html>