GWT可视化API VisualizationUtils.LoadVisualizationApi [英] GWT Visualization API VisualizationUtils.LoadVisualizationApi

查看:111
本文介绍了GWT可视化API VisualizationUtils.LoadVisualizationApi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设一个应用程序存在于多个不同的视图中,每个视图都包含多个相同类型的图。



我的问题是,是否需要加载可视化API每次我创建一个新图形时,都会按照此示例中的 http://代码.google.com / p / gwt-google-apis / wiki / VisualizationGettingStarted ,或者如果我一次加载可视化文件,是否不再需要创建Runnable以便在加载可视化文件时等待,可以显示?

解决方案

是的,我们无法使用Google Charts Offline。

b $ b

由于我们无法将Google Visualization API下载到我们的本地我们必须动态加载它们。



可运行的方式

  Runnable onLoadCallback = new Runnable(){$ b $ public void run()
{
PieChart pie = new PieChart(createTable(result ),createOptions());
pie.addSelectHandler(createSelectHandler(pie));
dataCHTabel.clear();
dataCHTabel.add(pie);
}
};
VisualizationUtils.loadVisualizationApi(onLoadCallback,PieChart.PACKAGE);

可视化API加载的新方法:

上面的行不推荐使用,并且加载所有图表的新方法是

  VisualizationUtils.loadVisualizationApi onLoadCallback,CoreChart.PACKAGE); 

通过在应用程序加载时加载所有程序包



通过在我的主页上添加下面的代码( appname.html

 < script type =text / javascriptsrc =http://www.google.com/jsapi>< / script> 
< script type =text / javascript>
google.load(visualization,1,{'packages':[corechart]});
< / script>

corechart软件包包含新版本的区域,栏,列,行,饼图,并分散可视化,这些以前由单独的包加载。

然后

  PieChart pie =新的PieChart(createTable(result),createOptions()); 
pie.addSelectHandler(createSelectHandler(pie));
dataCHTabel.clear();
dataCHTabel.add(pie);

geochart不包含在核心内所以,如果你想加载地理图表,你必须添加

  google.load('visualization','1',{'packages':['geochart']}); 


Assume an application exists where you have multiple different views, each containing multiple graphs of the same type.

My question is, do I need to load the visualization API each time I create a new graph as shown in this example http://code.google.com/p/gwt-google-apis/wiki/VisualizationGettingStarted, or if I load the visualization once, do I no longer have to create a Runnable in order to wait when the visualization is loaded so the data can be displayed?

解决方案

Yes,We cannot use Google Charts Offline.

As we cannot download the Google Visualization api to our local machine,We have to load them dynamically.

The runnable way

  Runnable onLoadCallback = new Runnable() {
                      public void run() 
                      {
  PieChart pie = new PieChart(createTable(result), createOptions());
  pie.addSelectHandler(createSelectHandler(pie));
   dataCHTabel.clear();
    dataCHTabel.add(pie);
    }
    };
   VisualizationUtils.loadVisualizationApi(onLoadCallback, PieChart.PACKAGE);

New way of Visualization API loading:

The above line is deprecated and the new way of loading all charts is

VisualizationUtils.loadVisualizationApi(onLoadCallback, CoreChart.PACKAGE);  

By Loading all packages while app loading

By adding the below code on my host page(appname.html)

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
 <script type="text/javascript">
    google.load("visualization", "1", {'packages' : ["corechart"] });
 </script>

The corechart package includes the code for the new versions of the area, bar, column, line, pie, and scatter visualizations, which were previously loaded by separate packages.

and then

 PieChart pie = new PieChart(createTable(result), createOptions());
 pie.addSelectHandler(createSelectHandler(pie));
 dataCHTabel.clear();
 dataCHTabel.add(pie);

geochart not included in core So ,And if you want to load geo chart ,you have to add

google.load('visualization', '1', {'packages': ['geochart']});

这篇关于GWT可视化API VisualizationUtils.LoadVisualizationApi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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