如何使用谷歌图表API图表、如何使用、API

2023-09-05 09:33:18 作者:一生只够爱一人

我使用的是谷歌的图表API中的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

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


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

<的WebView机器人:ID =@ + ID / char_view
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:能见度=看见/>


    <的TextView
        机器人:layout_width =FILL_PARENT
        机器人:layout_height =WRAP_CONTENT
        机器人:文本=@字符串/你好/>

< / LinearLayout中>
 

解决方案 20大数据可视化工具测评,一定有你不知道的宝藏 丨城市数据派

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

  webview.loadUrl(CHART_URL);
 

添加到您的清单

 <使用-权限的Andr​​oid:名称=android.permission.INTERNET对>< /使用-许可>
 

但如果你正在寻找如何绘制饼图机器人,你可以看到这个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