Android 版 FusionCharts 使用问题
我想在 android 2.2 中使用 FusionCharts(可能在模拟器上)。 我尝试使用 Javascript 和 HTML,但没有得到预期的结果。
有什么帮助吗?
我的代码如下:
WebView web;
/** Called when the activity is first created. */
@Override
public void on Create(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
web=(WebView)findViewById(R.id.webView1);
web.loadUrl("file:///android_asset/Fusioncharts/myChart.html");
}
}
还有我的 html、xml 文件:
<html>
<head>
<title>My First chart using FusionCharts
</title>
<script type="text/javascript" src="JavaScripts/FusionCharts.js">
</script>
</head>
<body>
<div id="chartContainer">FusionCharts will load here!
</div>
<script type="text/javascript">
<!--
var myChart = new FusionCharts("Pie2D.swf? dataURL=Data.xml","myChartId", "400", "300", "0", "1" );
myChart.setXMLUrl("Data.xml");
myChart.render("chartContainer");
// -->
</script>
</body>
</html>
和 Data.xml:
上面的代码只是显示:FusionCharts 将在此处加载!
谢谢
斯内哈
I wanted to use FusionCharts with android 2.2 (may be on emulator).
I tried using Javascript and the HTML but did not get the expected result.
Any help??
My code is as follows :
WebView web;
/** Called when the activity is first created. */
@Override
public void on Create(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
web=(WebView)findViewById(R.id.webView1);
web.loadUrl("file:///android_asset/Fusioncharts/myChart.html");
}
}
Also my html,xml files :
<html>
<head>
<title>My First chart using FusionCharts
</title>
<script type="text/javascript" src="JavaScripts/FusionCharts.js">
</script>
</head>
<body>
<div id="chartContainer">FusionCharts will load here!
</div>
<script type="text/javascript">
<!--
var myChart = new FusionCharts("Pie2D.swf? dataURL=Data.xml","myChartId", "400", "300", "0", "1" );
myChart.setXMLUrl("Data.xml");
myChart.render("chartContainer");
// -->
</script>
</body>
</html>
and Data.xml :
The above code just displays me : FusionCharts will load here!
Thanks
Sneha
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
编辑>新内容:
您可能需要为 WebView 启用 JavaScript 和插件:
http:// /developer.android.com/reference/android/webkit/WebView.html
WebView 中的“安装 Flash 插件”是什么意思?
如何在 Webview 中启用 Flash 插件?
另外,您可能需要设置SWF 和 JS 文件的正确路径。请在此处调试或附加代码。
旧内容:
似乎存在 JavaScript 错误或 FusionCharts 未加载以进行渲染,如 Duniyadnd 所述。
请检查 Android 调试(使用
adb logcat
或其他进程)是否跟踪到任何错误。此外,我使用 PhoneGap 做了一个实现,您可以从以下位置查看:
PhoneGap API to query call-logs
这是一个小型的 PhoneGap Android 应用程序,它具有 FusionCharts 来显示设备的呼叫日志。虽然这篇文章展示了创建插件来获取调用日志,但您可能会派生出您需要的其他元素。希望这可能有所帮助。
EDIT> NEW CONTENT:
You might need to enable JavaScript and plugins for the WebView:
http://developer.android.com/reference/android/webkit/WebView.html
What does "install Flash plugin" in WebView mean?
How to Enable Flash Plugin in Webview?
Also you might need to set proper path to the SWF and JS files. Please debug or attach code here.
OLD CONTENT:
There seems to be a JavaScript error or FusionCharts not getting loaded to do the rendering as stated by Duniyadnd.
Please check the Android debug (using
adb logcat
or other processes) if it traces any error.Moreover, I did an implementation using PhoneGap which you can check-out from:
PhoneGap API to query call-logs
This is a small PhoneGap Android application which has FusionCharts to show call logs from the device. The post though showcases creation of plugin to get the calllog, you might derive the other elements which you require. Hope this might help.