Das ist mein Problem: Ich spielte mit der JavaScript-Bibliothek von E-Charts wollte ich die Bilddaten abrufen (ich weiß, es gibt eine Sicherung als Bild Toolbox). Wenn ich versuche, die Funktion getDataUrl
zuzugreifen oder getConnectedDataUrl
, erhalte ich folgende Fehlermeldung:Javascript Browser Inspektor Konsole vs Quellcode
"myChart.getDataUrl is not a function"
Aber wenn ich versuche, das gleiche auf dem Browser zu tun (oder Firebug) Konsole, erhalte ich die Informationen, die ich will. Wenn ich get_data()
auf der Konsole rufe, bekomme ich auch den Fehler, den ich vorher erwähnt habe. Ich bin verwirrt.
Was mache ich falsch?
Es ist der Beispielcode:
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<button type="button" onclick="get_data()">holi</button>
<div id="main" style="width:400px;height:300px;"></div>
<script src="echarts.min.js"></script>
<script type="text/javascript">
// based on prepared DOM, initialize echarts instance
var myChart = echarts.init(document.getElementById('main'));
// specify chart configuration item and data
var option = {
title: {
text: 'Test'
},
tooltip: {},
legend: {
data:['Cosas']
},
xAxis: {
data: ["asdf","qwerty","lol"]
},
yAxis: {},
series: [{
name: 'Cosas',
type: 'bar',
data: [1, 3, 5]
}],
toolbox: {
show : true,
feature : {
mark : {show: false},
saveAsImage : {show: true, title: "save"}
}
}
};
// use configuration item and data specified to show chart
myChart.setOption(option);
function get_data(){
return myChart.getConnectedDataUrl();
};
</script>
</body>
</html>
Sie haben Recht. Vielen Dank. –