Monday, May 7, 2018

Re: Have charts to work with a RootPanel based application

i tried something like this

public class TestFrame extends Composite  {

   
PieChart pieChart ;    
   
   
public TestFrame() {    
           
       
VerticalPanel verticalPanel =  getPnl();
        initWidget
( verticalPanel );
       
       
Button btn = new Button("graph");
        btn
.setSize("100%", "100px");        
        btn
.addClickHandler(new ClickHandler() {
           
@Override
           
public void onClick(ClickEvent event) {
                setViewPieChart
();
           
}});        
        verticalPanel
.add(btn);
       
   
}
   
   
public static VerticalPanel getPnl(){
       
VerticalPanel verticalPanel = new VerticalPanel();
        verticalPanel
.setWidth("300px");
        verticalPanel
.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);

       
return verticalPanel;
   
}
   
   
private void setViewPieChart() {
       
       
ChartLoader chartLoader = new ChartLoader(ChartPackage.CORECHART);
        chartLoader
.loadApi(new Runnable() {
           
@Override
           
public void run() {
               
SimpleLayoutPanel layoutPanel = new SimpleLayoutPanel();
               
PieChart pieChart = (PieChart)getPieChart();
                layoutPanel
.setWidget(getPieChart());
                pieChart
.draw(getDataTable());
               
               
RootPanel.get().clear();
               
RootPanel.get().add(new TestFrame2(layoutPanel));
       
}});    
       
   
}    
   
   
private Widget getPieChart() {
       
if (pieChart == null) {
            pieChart
= new PieChart();
       
}
       
return pieChart;
   
}
}


    **********
   
public class TestFrame2 extends Composite  {

   
public TestFrame2(SimpleLayoutPanel layoutPanel) {    
           
       
VerticalPanel verticalPanel =  getPnl();
        initWidget
( verticalPanel );
       
        verticalPanel
.add(layoutPanel);
       
   
}
   
   
public static VerticalPanel getPnl(){
       
VerticalPanel verticalPanel = new VerticalPanel();
        verticalPanel
.setWidth("300px");
        verticalPanel
.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);

       
return verticalPanel;
   
}
}


--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment