【问题标题】:how to use Google Line Chart API for passing dynamic data in Blackberry application?如何使用 Google Line Chart API 在 Blackberry 应用程序中传递动态数据?
【发布时间】:2014-05-10 08:39:36
【问题描述】:

我想将我的数组数据传递给 URL。

我的代码是:

    String[] pointArray=(String[]) hashtable.get("point");


// where all values are coming from hashtable of my webservice.I want to pass this array as a chart data for line graph.

BrowserFieldConfig myBrowserFieldConfig = new BrowserFieldConfig();
myBrowserFieldConfig.setProperty(BrowserFieldConfig.NAVIGATION_MODE,BrowserFieldConfig.NAVIGATION_MODE_POINTER);
BrowserField browserField = new BrowserField(myBrowserFieldConfig);
add(browserField);

String url="http://chart.apis.google.com/chart?&cht=lc&chco=000000&chds=0,10&chdlp=b&chxt=x,y" +
"&chg=1.04,0,5,1&chds=0,30&chco=3072F3,ff0000,00aaaa&chls=2,4,1&chm=s,FF0000,0,-1,0|s,0000ff,1,-1,0|s,00aa00,2,-1,0" +
"&chs=480x280&chof=validate&chd=t:100,200,300,400,500,600,700&chd=t:"+point";

 browserField.requestContent(url);

但它给了我这个错误:

The parameter 'chd=t:[Ljava.Lang.String@d297c570f' does not match the expected format.

我想将我的数组传递给此 URL 以获取图表数据。如何解决这个问题?

【问题讨论】:

    标签: java google-maps-api-3 blackberry blackberry-simulator


    【解决方案1】:

    在网址中

    String url="http://chart.apis.google.com/chart?&cht=lc&chco=000000&chds=0,10&chdlp=b&chxt=x,y"
    +"&chg=1.04,0,5,1&chds=0,30&chco=3072F3,ff0000,00aaaa&chls=2,4,1&chm=s,FF0000,0,-1,0|s,0000ff,1,-1,0|s,00aa00,2,-1,0"
    +"&chs=480x280&chof=validate&chd=t:100,200,300,400,500,600,700&chd=t:"
    +point;
    

    你的点用 point.toString() 转换并附加到这部分的 url

    "&chd=t:"+point;
    

    这是 chd 第二次出现在 url 中。所以实际上只考虑最后一个 chd 值。不考虑第一个 chd=t:100,200,300,400,500,600,700。

    如果您想传递 chd,它必须位于 format chd=t:val,val,val 中,其中 val 代表您数据中的一个值。见an example with a data chd=t:-5,30,-30,50,80,200

    并且 chd 应该只在 url 中出现一次。

    所以你的网址代码是这样的:

    String url="http://chart.apis.google.com/chart?&cht=lc&chco=000000&chds=0,10&chdlp=b&chxt=x,y"
    + "&chg=1.04,0,5,1&chds=0,30&chco=3072F3,ff0000,00aaaa&chls=2,4,1&chm=s,FF0000,0,-1,0|s,0000ff,1,-1,0|s,00aa00,2,-1,0"
    + "&chs=480x280&chof=validate&chd=t:"+<comma separated list of values>;
    

    【讨论】:

    • 感谢 Marius Zilenas。它对我真的很有帮助,我的问题已经通过这个解决方案解决了。
    猜你喜欢
    • 2012-03-25
    • 2017-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多