I am using a google chart API in this
how can i use this chart in android application?
here is my code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String url = "http://chart.apis.google.com/chart?cht=p3&chs=500x200&chd=e:TNTNTNGa&chts=000000,16&chtt=A+Better+Web&chl=Hello|Hi|anas|Explorer&chco=FF5533,237745,9011D3,335423&chdl=Apple|Mozilla|Google|Microsoft";
WebView mCharView = (WebView) findViewById(R.id.char_view);
mCharView.loadUrl(url);
}
and the XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<WebView android:id="@+id/char_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="visible"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
</LinearLayout>
Google chart tools are powerful, simple to use, and free. Try out our rich gallery of interactive charts and data tools.
The Google Chart API is an extremely simple tool that lets you easily create a chart from some data and embed it in a webpage. You embed the data and formatting parameters in an HTTP request, and Google returns a PNG image of the chart.
You load some Google Chart libraries, list the data to be charted, select options to customize your chart, and finally create a chart object with an id that you choose. Then, later in the web page, you create a <div> with that id to display the Google Chart. That's all you need to get started.
If you want to load your chart like @Rajesh said you have to use a webview and than load the url of your chart by:
webview.loadUrl(CHART_URL);
add to your manifest
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
but if you are looking how to draw pie chart in android you can see this tutorial it has sample code attached to
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With