0

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

Smitha
  • 6,110
  • 24
  • 90
  • 161
  • I'm guessing this can be run off a browser as well? Did you check for javascript errors as well? the gap between "Pie2D.swf? dataURL=Data.xml" concerns me as does "myChartId" - shouldn't that be the id - chartContainer? – Duniyadnd Sep 28 '11 at 04:23
  • nope. this is not working even on browser as well. And I have corrected the gap. But id is fine. – Smitha Sep 28 '11 at 04:35
  • If it doesn't load with any error message, it's possible you are not calling the javascript file from the correct location. Make sure that "JavaScripts/FusionCharts.js" is correctly labeled relative to your document. If you're on a Linux box, ensure that your files have the correct case sensitive letters – Duniyadnd Sep 28 '11 at 04:39
  • Hi Sneha, Can you check if there is any error in JavaScript through Firebug? Also check if FusionCharts.js is getting loaded. – sudipto Sep 28 '11 at 04:41
  • Hi Sneha , Can i see your full code because i want to check that whether have you used any method to use java script or html in java code because you are simply calling java html but you are not declaring any method in java class to use it –  Jan 10 '12 at 05:37

1 Answers1

1

EDIT> NEW CONTENT:

You might need to enable JavaScript and plugins for the WebView:

webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setPluginsEnabled(true);

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.

Community
  • 1
  • 1
sudipto
  • 2,472
  • 1
  • 17
  • 21
  • thanks all. But as phonegap is a third party library, I don't want to go for it – Smitha Sep 28 '11 at 04:56
  • Yes, Understood. You can also do it using native code. I would need to check you code once and let you know. Meanwhile, please let me know if you have Flash player in your emulator. – sudipto Sep 28 '11 at 05:03
  • yep.. I have flash player installed. – Smitha Sep 28 '11 at 06:03
  • In that case, we would need to check if the HTML which you are using is working in normal browsers or not. – sudipto Sep 28 '11 at 09:02
  • Its not working even on my IE 7 browser in my Windows XP desktop (myChart.html). It's displaying the same result.(FusionCharts will load here! ) – Smitha Sep 28 '11 at 11:24
  • Sneha - run it in Firefox, and run Firebug or the Javascript error log (f12) to show you what the error is. – Duniyadnd Sep 28 '11 at 14:23
  • Oh,.. I don't have Firefox and my working environment doesn't allow me to install it :-( – Smitha Sep 29 '11 at 03:31
  • You can enable IE's Scrip Debugging options from Tools > Internet Options > Advanced tab and untick "Disable script debugging" and tick "Display a notification about every script error" – sudipto Sep 29 '11 at 11:20