Example usage for com.google.gwt.visualization.client VisualizationUtils loadVisualizationApi

List of usage examples for com.google.gwt.visualization.client VisualizationUtils loadVisualizationApi

Introduction

In this page you can find the example usage for com.google.gwt.visualization.client VisualizationUtils loadVisualizationApi.

Prototype

public static void loadVisualizationApi(String version, Runnable onLoad, String... packages) 

Source Link

Usage

From source file:com.google.gwt.visualization.sample.hellovisualization.client.VisualizationDemo.java

License:Apache License

public void onModuleLoad() {
    VisualizationUtils.loadVisualizationApi(new Runnable() {
        public void run() {
            final VerticalPanel vp = new VerticalPanel();
            vp.getElement().getStyle().setPropertyPx("margin", 15);
            RootPanel.get().add(vp);/*from   w  w  w .  j av a 2 s  . c o  m*/
            vp.add(new Label("Google Visualization with GWT demo."));
            vp.add(tabPanel);
            tabPanel.setWidth("800");
            tabPanel.setHeight("600");
            tabPanel.add(createPieChart(), "Pie Chart");
            tabPanel.add(createTable(), "Table");
            tabPanel.add(createDataView(), "DataView");
            tabPanel.selectTab(0);
        }
    }, PieChart.PACKAGE, Table.PACKAGE);
}

From source file:com.radoslavhusar.tapas.war.client.app.VisualizationDemo.java

License:Apache License

public void onModuleLoad() {
    VisualizationUtils.loadVisualizationApi(new Runnable() {

        public void run() {
            final VerticalPanel vp = new VerticalPanel();
            vp.getElement().getStyle().setPropertyPx("margin", 15);
            RootPanel.get().add(vp);//from  w  w w. j a va2  s .com
            vp.add(new Label("Google Visualization with GWT demo."));
            vp.add(tabPanel);
            tabPanel.setWidth("800");
            tabPanel.setHeight("600");
            tabPanel.add(createPieChart(), "Pie Chart");
            tabPanel.add(createTable(), "Table");
            tabPanel.add(createDataView(), "DataView");
            tabPanel.selectTab(0);
        }
    }, PieChart.PACKAGE, Table.PACKAGE);
}

From source file:com.tasktop.c2c.server.profile.web.ui.client.GoogleVisLoader.java

License:Open Source License

public static void ensureGoogleVisLoaded(final Runnable afterLoad) {
    if (loaded) {
        afterLoad.run();/*from   w w w . ja v a  2  s .c o  m*/
        return;
    }

    VisualizationUtils.loadVisualizationApi(new Runnable() {
        @Override
        public void run() {
            loaded = true;
            afterLoad.run();
        }
    }, "corechart", ImageSparklineChart.PACKAGE);
}

From source file:com.youtube.statistics.client.YtStatistics.java

License:Apache License

/**
 * This is the entry point method./*  w  ww  .j  ava2s . c  o m*/
 */
public void onModuleLoad() {
    VisualizationUtils.loadVisualizationApi(new Runnable() {
        public void run() {
            loadUi();
        }
    }, ColumnChart.PACKAGE, AnnotatedTimeLine.PACKAGE);
}

From source file:org.opendatakit.aggregate.client.popups.VisualizationPopup.java

License:Apache License

public VisualizationPopup(FilterSubTab filterSubTab) {
    super();// www  . ja  v a  2  s.  c  o  m

    formId = filterSubTab.getDisplayedFilterGroup().getFormId();
    headers = filterSubTab.getSubmissionTable().getHeaders();
    submissions = filterSubTab.getSubmissionTable().getSubmissions();

    chartType = new EnumListBox<ChartType>(ChartType.values(), VIZ_TYPE_TOOLTIP, VIZ_TYPE_BALLOON);
    chartType.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            updateUIoptions();
        }
    });

    columnList = new ColumnListBox(headers, false, true, "Column to Graph",
            "Select the column you wish to graph.");
    columnList.addChangeHandler(new ColumnChangeHandler());
    dataList = new ColumnListBox(headers, false, true, "Column to get data values from",
            "Select the column to get the numerical values from.");
    dataList.addChangeHandler(new ColumnChangeHandler());
    geoPoints = new KmlSettingListBox(GEOPOINT_TOOLTIP, GEOPOINT_BALLOON);

    // The Maps API is always loaded.

    chartApiLoaded = false;
    VisualizationUtils.loadVisualizationApi(new Runnable() {
        public void run() {
            chartApiLoaded = true;
            updateUIoptions();
        }
    }, PieChart.PACKAGE, Table.PACKAGE);

    SecureGWT.getFormService().getGpsCoordnates(formId, new AsyncCallback<KmlSettings>() {
        public void onFailure(Throwable caught) {
            AggregateUI.getUI().reportError(caught);
        }

        public void onSuccess(KmlSettings result) {
            geoPoints.updateValues(result.getGeopointNodes());
        }
    });

    // create radio button
    // NOTE: need to apply the click handler to both because can't use value
    // change. Because browser limitations prevent ValueChangeEvents from being
    // sent when the radio button is cleared as a side effect of another in the
    // group being clicked.

    FlexTable tallyTable = new FlexTable();
    tallyOccurRadio = new RadioButton(RADIO_GROUP, BasicConsts.EMPTY_STRING);
    tallyOccurRadio.addClickHandler(new RadioChangeClickHandler());
    tallyOccurRadio.setValue(true);
    tallyTable.setWidget(0, TALLY_CHOICE, tallyOccurRadio);

    FlexTable sumTable = new FlexTable();
    sumColumnsRadio = new RadioButton(RADIO_GROUP, SUM_COLUMNS_TXT);
    sumColumnsRadio.addClickHandler(new RadioChangeClickHandler());
    sumRadioTxt = new Label(BasicConsts.EMPTY_STRING);
    sumTable.setWidget(1, SUM_CHOICE, sumColumnsRadio);
    sumTable.setWidget(1, SUM_CHOICE_COLUMN, dataList);
    sumTable.setWidget(1, SUM_CHOICE_TXT, sumRadioTxt);

    executeButton = new AggregateButton(BasicConsts.EMPTY_STRING, "Execute the Vizualization",
            "Create the selected Vizualization.");
    executeButton.addClickHandler(new ExecuteVisualization());

    typeControlBar = new FlexTable();
    typeControlBar.setHTML(0, VIZ_TYPE_TEXT, TYPE_TXT);
    typeControlBar.setWidget(0, VIZ_TYPE_LIST, chartType);
    typeControlBar.setHTML(0, COLUMN_TEXT, COLUMN_TXT);
    typeControlBar.setWidget(0, COLUMN_LIST, columnList);
    typeControlBar.setWidget(0, BUTTON, executeButton);

    FlexTable topSelectionRow = new FlexTable();
    topSelectionRow.addStyleName("stretch_popup_header");
    topSelectionRow.setWidget(0, 0, typeControlBar);
    topSelectionRow.setWidget(0, CLOSE, new ClosePopupButton(this));
    topSelectionRow.getCellFormatter().addStyleName(0, CLOSE, "popup_close_cell");

    FlexTable tabulationBar = new FlexTable();
    tabulationBar.setHTML(0, VALUE_TEXT, TABULATION_TXT);
    tabulationBar.setWidget(0, VALUE_LIST, tallyTable);
    tabulationBar.setWidget(1, VALUE_LIST, sumTable);

    FlexTable bottomSelectionRow = new FlexTable();
    bottomSelectionRow.addStyleName("stretch_popup_header");
    bottomSelectionRow.setWidget(0, 0, tabulationBar);

    // setup the window size
    chartPanel = new SimplePanel();
    Integer height = (Window.getClientHeight() * 5) / 6;
    Integer width = (Window.getClientWidth() * 5) / 6;
    chartPanel.setHeight(height.toString() + RESIZE_UNITS);
    chartPanel.setWidth(width.toString() + RESIZE_UNITS);

    FlowPanel layoutPanel = new FlowPanel();
    layoutPanel.add(topSelectionRow);
    layoutPanel.add(bottomSelectionRow);
    layoutPanel.add(chartPanel);

    setWidget(layoutPanel);
    chartType.setItemSelected(0, true);
    updateUIoptions();
    updateColumnGraphingDesc();
}