Code To Embeded Google Chart in WebView

by Preetha 2012-09-14 11:23:21

Google Chart Tools provide a funny Chart Wizard to generate image charts. By using WebView, it's easy to embedded the charts inside your App.

In the Chart Wizard, select your chart, enter data, lets the wizard generate the chart, copy the link of "Paste link in email or IM" to embeddedWeb in the code.

package com.AndroidEmbeddedWebView;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class AndroidEmbeddedWebViewActivity extends Activity {

WebView embeddedWebView;
String embeddedWeb = "http://chart.apis.google.com/chart?chxl=0Neutral
Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec&chxt=x,y&chs=300x300&cht=r&chco=FF0000&chd=t:63,64,67,73,77,81,85,86,85,81,74,67,63&chls=2,4,0&chm=B,FF000080,0,0,0";

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
embeddedWebView = (WebView)findViewById(R.id.embeddedwebview);
embeddedWebView.loadUrl(embeddedWeb);
}
}

Tagged in:

1017
like
0
dislike
0
mail
flag

You must LOGIN to add comments