diff --git a/web/index.css b/web/index.css index c5eaab3..98a8b4e 100644 --- a/web/index.css +++ b/web/index.css @@ -26,6 +26,17 @@ body { top: 60px; bottom: 50px; } +.optionTips { + position: absolute; + top: 3px; + right: 10px; +} +.previewTips { + position: absolute; + top: 3px; + left: 10px; + color: #fff; +} .run { display: block; position: fixed; @@ -43,8 +54,12 @@ body { .run:active, .run:visited { color: #fff; } - +#svg { + position: absolute; + top: 50%; + margin-top: -200px; +} svg { display: block; - margin: 30px auto; + margin: auto; } \ No newline at end of file diff --git a/web/index.html b/web/index.html index 8cd9749..54b0ee8 100644 --- a/web/index.html +++ b/web/index.html @@ -12,11 +12,16 @@
Go Charts
-
+
+ +
ECharts配置
+
+
图表SVG效果
运行 + \ No newline at end of file diff --git a/web/index.js b/web/index.js index 9e5e65a..a823c88 100644 --- a/web/index.js +++ b/web/index.js @@ -8,7 +8,22 @@ editor.setSize("100%", height); function run() { var option = editor.getValue(); - axios.post("/", JSON.parse(option)).then(function(resp) { + var data = null; + try { + if (option.indexOf("option = ") !== -1) { + var fn = new Function("var " + option + ";return option;"); + data = fn(); + } else { + data = JSON.parse(option); + } + } catch (err) { + alert(err.message); + return; + } + + axios.post("/", data).then(function(resp) { document.getElementById("svg").innerHTML = resp; + }).catch(function(err) { + alert(err.message); }); } \ No newline at end of file