Run the following code, click the refresh button, followed by two prepend clicks.
As the highchart documentation notes (http://www.highcharts.com/stock/ref/#series-object) the data array might not contain all point data. It advises to use series.options.data instead - which always returns the x and y values. I have had to temporarily introduce an alternative JSNI call to fix this problem for our use case.
Could you please add the option to retrieve the data points from the series.options.data?
!/usr/bin/java
@OverridepublicvoidonModuleLoad(){finalStockChartchart=newStockChart();chart.setPersistent(true);chart.getXAxis().setType(Type.DATE_TIME);finalSeriesseries=chart.createSeries();chart.addSeries(series);SimplePanelsp=newSimplePanel(chart);RootPanel.get().add(sp);List<Point>points=newArrayList<Point>();longtime=System.currentTimeMillis();lastTime=time;for(intx=0;x<10;x++){doublerand=100+(int)(Math.random()*1000);lastTime=time+TimeUnit.MINUTES.toMillis(10*x);points.add(newPoint(Long.valueOf(lastTime),Double.valueOf(rand)));}for(Pointpoint:points){series.addPoint(point,false,false,false);}Buttonb=newButton("refresh");b.addClickHandler(newClickHandler(){@OverridepublicvoidonClick(finalClickEventeventparam){chart.redraw();}});Buttonb2=newButton("prepend");b2.addClickHandler(newClickHandler(){privateintcounter=1;@OverridepublicvoidonClick(ClickEventeventparam){List<Point>points=newArrayList<Point>();longtime=System.currentTimeMillis()-TimeUnit.HOURS.toMillis(10*counter++);longlastTime=time;for(intx=0;x<10;x++){doublerand=100+(int)(Math.random()*1000);lastTime=time+TimeUnit.MINUTES.toMillis(10*x);points.add(newPoint(Long.valueOf(lastTime),Double.valueOf(rand)));}checkExisting(series.getPoints());points.addAll(Arrays.asList(series.getPoints()));series.setPoints(points.toArray(newPoint[]{}));}privatevoidcheckExisting(Point[]pointsparam){for(inti=0;i<pointsparam.length;i++){Pointpoint=pointsparam[i];if(point.getX()==null||point.getY()==null){System.out.println("existing point "+i+" is bad...");}}}});Buttonb3=newButton("append");b3.addClickHandler(newClickHandler(){@OverridepublicvoidonClick(ClickEventeventparam){doublerand=100+(int)(Math.random()*1000);lastTime=lastTime+TimeUnit.MINUTES.toMillis(5);series.addPoint(Long.valueOf(lastTime),Double.valueOf(rand));}});RootPanel.get().add(b);RootPanel.get().add(b2);RootPanel.get().add(b3);}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
Run the following code, click the refresh button, followed by two prepend clicks.
As the highchart documentation notes (http://www.highcharts.com/stock/ref/#series-object) the data array might not contain all point data. It advises to use series.options.data instead - which always returns the x and y values. I have had to temporarily introduce an alternative JSNI call to fix this problem for our use case.
Could you please add the option to retrieve the data points from the series.options.data?
!/usr/bin/java