Example usage for com.google.gwt.visualization.client DataView setColumns

List of usage examples for com.google.gwt.visualization.client DataView setColumns

Introduction

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

Prototype

public final native void setColumns(JsArrayInteger columnIndices) ;

Source Link

Usage

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

License:Apache License

/**
 * Creates a table and a view and shows both next to each other.
 *
 * @return a panel with two tables.// w w  w.j  a v  a 2s  .  c  o  m
 */
private Widget createDataView() {
    Panel panel = new HorizontalPanel();
    DataTable table = DataTable.create();

    /* create a table with 3 columns */
    table.addColumn(ColumnType.NUMBER, "x");
    table.addColumn(ColumnType.NUMBER, "x * x");
    table.addColumn(ColumnType.NUMBER, "sqrt(x)");
    table.addRows(10);
    for (int i = 0; i < table.getNumberOfRows(); i++) {
        table.setValue(i, 0, i);
        table.setValue(i, 1, i * i);
        table.setValue(i, 2, Math.sqrt(i));
    }
    /* Add original table */
    Panel flowPanel = new FlowPanel();
    panel.add(flowPanel);
    flowPanel.add(new Label("Original DataTable:"));
    Table chart = new Table();
    flowPanel.add(chart);
    chart.draw(table);

    flowPanel = new FlowPanel();
    flowPanel.add(new Label("DataView with columns 2 and 1:"));
    /* create a view on this table, with columns 2 and 1 */
    Table viewChart = new Table();
    DataView view = DataView.create(table);
    view.setColumns(new int[] { 2, 1 });
    flowPanel.add(viewChart);
    panel.add(flowPanel);
    viewChart.draw(view);

    return panel;
}

From source file:com.rhizospherejs.gwt.showcase.client.gviz.GoogleVisualizationTab.java

License:Open Source License

private GoogleVisualizationTab() {
    initWidget(ui.createAndBindUi(this));
    dobInput.setValue(new Date());
    dobInput.setFormat(new DateBox.DefaultFormat(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)));

    // Ensures that both the Google Visualization APIs and Rhizosphere libraries
    // are loaded.
    VisualizationUtils.loadVisualizationApi(new Runnable() {
        @Override//from w ww.ja  va2 s . c  om
        public void run() {
            RhizosphereLoader.getInstance().ensureInjected(new Runnable() {
                @Override
                public void run() {
                    // Populate the DataTable with some sample data.
                    initDataTable();

                    // Setup configuration options for both Rhizosphere and the
                    // scatterplot.
                    initOptions();

                    DataView view = DataView.create(dataTable);
                    view.setColumns(new int[] { 1, 2 });
                    scatterChart = new ScatterChart(view, scatterChartOptions);
                    chartContainer.clear();
                    chartContainer.add(scatterChart);

                    rhizosphere = new GVizRhizosphere(dataTable, rhizosphereOptions);
                    rhizosphere.setWidth("400px");
                    rhizosphere.setHeight("400px");
                    rhizosphereContainer.clear();
                    rhizosphereContainer.add(rhizosphere);
                }
            });
        }
    }, "corechart");
}

From source file:com.rhizospherejs.gwt.showcase.client.gviz.GoogleVisualizationTab.java

License:Open Source License

@Override
public void dataChanged() {
    DataView view = DataView.create(dataTable);
    view.setColumns(new int[] { 1, 2 });
    scatterChart.draw(view, scatterChartOptions);
    rhizosphere.draw(dataTable, GVizRhizosphere.Options.wrap(rhizosphereOptions));
}