GWT Google可视化 - 后续重绘会更改Y轴步骤的数量? [英] GWT Google Visualization - subsequent redraws change number of Y axis steps?

查看:84
本文介绍了GWT Google可视化 - 后续重绘会更改Y轴步骤的数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在我的图表上绘制了最初的ajax调用google可视化工具,然后使用定时器每5秒重新绘制一次。每次重绘时,Y轴上的步数会改变它们的值和频率(有时您会更频繁地使用它们)。注意图的值保持完全相同。我已经包含了2个截图来向你展示它的两个步骤。在随后的每一次重绘中,它都会从一种姿态变为另一种姿态。注意右侧892和900上的不同情绪值,即使两种情况下图上的值都是903。

stack.imgur.com/gXAJQ.pngalt =Stance 1>





我相信这可能是因为双Y轴。在每次重绘时,焦点作为主Y轴从一个变为另一个。我认为这可能得到以下事实的支持:在第一个价格中显示为第一个参数,而在第二个中反之亦然。
有任何想法吗?

以下是我的客户端代码:

  public class GUI实现EntryPoint {

//创建远程服务代理以与服务器端数据服务交互
private final ChartDataServiceAsync chartDataSvc = GWT.create(ChartDataService.class) ;
私有AnnotatedTimeLine图;

public void onModuleLoad(){
//创建一个可视化API
//被加载时调用的回调函数。
Runnable onLoadCallback = new Runnable(){
public void run(){
Panel panel = RootPanel.get();
graph = new AnnotatedTimeLine(1000px,500px);
//用于css文件
graph.addStyleName(timeLine);
panel.add(graph);
createTable();
}
};

//加载可视化api,传递onLoadCallback以称为
//当加载完成时。
VisualizationUtils.loadVisualizationApi(onLoadCallback,AnnotatedTimeLine.PACKAGE);

定时器timeoutTimer = new Timer(){
public void run(){
createTable();
// Window.alert(Reloaded chart。);
}
};
timeoutTimer.scheduleRepeating(1000 * 5);






  private选项createOptions(){
选项选项= Options.create();
options.setDisplayZoomButtons(true);
options.setDisplayAnnotations(false);
options.setAllowRedraw(true);
options.setDateFormat(MMMM dd,yyyy);
options.setDisplayDateBarSeparator(true);
options.setDisplayExactValues(true);
options.setDisplayRangeSelector(false);
options.setThickness(2);
options.setScaleColumns(0,1);
options.setScaleType(ScaleType.ALLMAXIMIZE);
Map< Integer,String> m1 = new LinkedHashMap< Integer,String>();
m1.put(0,。0000);
m1.put(1,######);
options.setNumberFormats(m1);
返回选项;
} // end createOptions()

private void createTable(){

final DataTable data = DataTable.create();
data.addColumn(ColumnType.DATE,Date);
data.addColumn(ColumnType.NUMBER,Price);
data.addColumn(ColumnType.NUMBER,Sentiment);

//设置回调对象。
AsyncCallback< List< PriceData>> callback = new AsyncCallback< List< PriceData>>(){
public void onFailure(Throwable caught){
// TODO:做一些有错误的事情。
System.out.println(RPC call failed!);
}

public void onSuccess(List< PriceData> result){
System.out.println(success!);
data.addRows(result.size());
for(int i = 0; i< result.size(); i ++){
String dateString = result.get(i).getDate();
DateTimeFormat form1 = DateTimeFormat.getFormat(dd / MM / yyyy HH:mm:ss);
日期d = form1.parse(dateString);
data.setValue(i,0,d);
data.setValue(i,1,result.get(i).getPrice());
data.setValue(i,2,i);
}
//创建图表可视化。
graph.draw(data,createOptions());

}
};
//拨打股票价格服务。
chartDataSvc.getChartData(Prices.csv,callback);
} // end createTable()

RPC调用只是从文件中提取数据服务器。

编辑:我注意到,如果我在选项allowRedraw(false)中设置所有这些问题将被解决。随后的重绘也存在一个问题,不会注意到数据文件中的更改,这也可以通过解决此问题来解决。所以allowRedraw函数的方式必须代表问题。但我真的需要允许重绘,因为现在每次后续重画都很慢,并且屏幕上有一个明显的闪光。

这可能是由于注释时间线图中的一个错误造成的:



请参阅 thread $ b

Issue 766 and 第107期


I am having a weird bug with GWT google visualization library wrapper, specifically AnnotatedTimeLine.

Namely, I draw my chart on the initial ajax call to google visualization tools, and then I redraw it every 5 seconds using a timer. Each time it redraws, the "steps" on Y axis change their values and frequency (sometimes you will have them in more frequent intervals). Note values of graph stay exactly the same. I've included 2 screenshots to show you 2 stances it goes from. On every subsequent redraw, it changes from one stance to another. Note different sentiment values on right side 892 and 900, even though the value on the graph is 903 in both cases.

I believe it might be because of double Y axis. On each redraw the focus as the "main" Y axis is changed from one to another. I think that might be supported by the fact that in first one Price is displayed as first parameter, whereas in the second one it is vice versa. Any ideas?

Here is my client side code:

public class GUI implements EntryPoint {

    // create  a remote service proxy to talk to server side-side data service
    private final ChartDataServiceAsync chartDataSvc = GWT.create(ChartDataService.class);  
    private AnnotatedTimeLine graph;

    public void onModuleLoad() {
    // Create a callback to be called when the visualization API
    // has been loaded.
    Runnable onLoadCallback = new Runnable() {
      public void run() {
          Panel panel = RootPanel.get();
          graph = new AnnotatedTimeLine("1000px", "500px");
          // used in css file
          graph.addStyleName("timeLine");
        panel.add(graph);
        createTable();
      }
    };

    // Load the visualization api, passing the onLoadCallback to be called
    // when loading is done.
    VisualizationUtils.loadVisualizationApi(onLoadCallback, AnnotatedTimeLine.PACKAGE);

    Timer timeoutTimer = new Timer() {
     public void run() {
            createTable();
//            Window.alert("Reloaded chart.");  
      }
    };
    timeoutTimer.scheduleRepeating(1000*5);

}

and

private Options createOptions() {
    Options options = Options.create();
    options.setDisplayZoomButtons(true);
    options.setDisplayAnnotations(false);
    options.setAllowRedraw(true);
    options.setDateFormat("MMMM dd, yyyy");
    options.setDisplayDateBarSeparator(true);
    options.setDisplayExactValues(true);
    options.setDisplayRangeSelector(false);
    options.setThickness(2);
    options.setScaleColumns(0,1);
    options.setScaleType(ScaleType.ALLMAXIMIZE);
    Map<Integer,String> m1 = new LinkedHashMap<Integer,String>();
    m1.put(0,".0000");
    m1.put(1, "######");
    options.setNumberFormats(m1);
    return options;
} // end createOptions()

private void createTable() {

    final DataTable data = DataTable.create();
    data.addColumn(ColumnType.DATE, "Date");
    data.addColumn(ColumnType.NUMBER, "Price");
    data.addColumn(ColumnType.NUMBER, "Sentiment");  

    // Set up the callback object.
    AsyncCallback<List<PriceData>> callback = new AsyncCallback<List<PriceData>>() {
      public void onFailure(Throwable caught) {
        // TODO: Do something with errors.
          System.out.println("RPC call failed!");
      }

      public void onSuccess(List<PriceData> result) {
        System.out.println("success!");
        data.addRows(result.size());
        for (int i = 0; i < result.size(); i++) {
          String dateString = result.get(i).getDate();
          DateTimeFormat form1 = DateTimeFormat.getFormat("dd/MM/yyyy HH:mm:ss");
          Date d = form1.parse(dateString);
          data.setValue(i, 0, d);
          data.setValue(i, 1, result.get(i).getPrice());
          data.setValue(i, 2, i);
        }
        // Create a chart visualization.
        graph.draw(data, createOptions());

      }
    };
    // Make the call to the stock price service.
    chartDataSvc.getChartData("Prices.csv", callback);
} // end createTable()

RPC call just fetches the data from the file on server.

Edit: I have noticed that if I set in options allowRedraw(false) all these problems will be solved. There was also a problem with subsequent redraws not noticing changes in the data file, which is solved with this as well. So the way allowRedraw functions must represent the problem. But I really need allow redraw since now each subsequent redraw is very slow and has an obvious flash on the screen.

解决方案

I think this might be due to a bug in the Annotated Time Line chart:

See here for the thread

Issue 766 and Issue 107

这篇关于GWT Google可视化 - 后续重绘会更改Y轴步骤的数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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