refactor: adjust charts preview
This commit is contained in:
parent
ebc566fc9d
commit
fea5649efb
3 changed files with 39 additions and 4 deletions
17
web/index.js
17
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);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue