如何使用谷歌图表API [英] How to use Google chart API

查看:107
本文介绍了如何使用谷歌图表API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是谷歌的图表API中的<一个href="http://chart.apis.google.com/chart?cht=p3&chs=500x200&chd=e%3aTNTNTNGa&chts=000000,16&chtt=A%20Better%20Web&chl=Hello%7CHi%7Canas%7CExplorer&chco=FF5533,237745,9011D3,335423&chdl=Apple%7CMozilla%7CGoogle%7CMicrosoft">this

我如何使用这个表中的Andr​​oid应用程序?

这是我的code

 公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);

       字符串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 =(web视图)findViewById(R.id.char_view);
        mCharView.loadUrl(URL);
    }
 

和XML

 &LT; XML版本=1.0编码=UTF-8&GT?;


&LT; LinearLayout中的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    机器人:方向=垂直&GT;

&LT;的WebView机器人:ID =@ + ID / char_view
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:能见度=看见/&GT;


    &LT;的TextView
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:文本=@字符串/你好/&GT;

&LT; / LinearLayout中&GT;
 

解决方案

如果您要加载图表就像@Rajesh说你要使用的WebView和比加载图表的网址:

  webview.loadUrl(CHART_URL);
 

添加到您的清单

 &LT;使用-权限的Andr​​oid:名称=android.permission.INTERNET对&GT;&LT; /使用-许可&GT;
 

但如果你正在寻找如何绘制饼图机器人,你可以看到这个<一href="http://www.artfulbits.com/articles/samples/aicharts/sample-viewer.aspx?sample=piesample">tutorial它连接到样品code

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>

解决方案

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

这篇关于如何使用谷歌图表API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆