Example usage for com.google.gwt.visualization.client DataTable addRows

List of usage examples for com.google.gwt.visualization.client DataTable addRows

Introduction

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

Prototype

public final native int addRows(int number) ;

Source Link

Usage

From source file:cmg.org.monitor.module.client.InviteUser.java

License:Open Source License

/**
 * Creates the data list system./*from  w  w w  .  j  a v  a  2s  . co  m*/
 *
 * @param result the result
 * @param filter the filter
 * @return the abstract data table
 */
public static AbstractDataTable createDataListSystem(List<InvitedUser> result, String filter) {
    DataTable dataListUser = DataTable.create();
    dataListUser.addColumn(ColumnType.STRING, "USERNAME");
    dataListUser.addColumn(ColumnType.STRING, "STATUS");
    dataListUser.addColumn(ColumnType.STRING, "ACTION");
    List<InvitedUser> listTemp = new ArrayList<InvitedUser>();
    if (filter.equalsIgnoreCase(defaultFilter)) {
        for (InvitedUser u : result) {
            listTemp.add(u);
        }
    } else {
        for (InvitedUser u : result) {
            if (u.getStatus().equalsIgnoreCase(filter)) {
                listTemp.add(u);
            }
        }
    }
    if (listTemp.size() > 0) {
        dataListUser.addRows(listTemp.size());
        for (int i = 0; i < listTemp.size(); i++) {
            InvitedUser u = listTemp.get(i);
            dataListUser.setValue(i, 0, "<div style=\"min-width:450px\">" + u.getEmail() + "</div>");
            if (u.getStatus().equalsIgnoreCase(filter_Active)) {
                String status = "<a style=\"margin-left:auto;margin-right:auto;\" class=\"stt_userActive\" title=\""
                        + filter_Active + "\"/>";
                dataListUser.setValue(i, 1, "<div style=\"min-width:450px\">" + status + "</div>");
                String html = HTMLControl.getButtonForActiveUser(u);
                dataListUser.setValue(i, 2, "<div style=\"min-width:220px\">" + html + "</div>");
            }
            if (u.getStatus().equalsIgnoreCase(filter_requesting)) {
                String status = "<a style=\"margin-left:auto;margin-right:auto;\" class=\"stt_inactive\" title=\""
                        + filter_requesting + "\"/>";
                dataListUser.setValue(i, 1, "<div style=\"min-width:450px\">" + status + "</div>");
                String html = HTMLControl.getButtonForRequestingUser(u);
                dataListUser.setValue(i, 2, "<div style=\"min-width:220px\">" + html + "</div>");
            }
            if (u.getStatus().equalsIgnoreCase(filter_pending)) {
                String status = "<a style=\"margin-left:auto;margin-right:auto;\" class=\"stt_pending\" title=\""
                        + filter_pending + "\"/>";
                dataListUser.setValue(i, 1, "<div style=\"min-width:450px\">" + status + "</div>");
                String html = HTMLControl.getButtonForPendingUser(u);
                dataListUser.setValue(i, 2, "<div style=\"min-width:220px\">" + html + "</div>");
            }
        }
    }

    return dataListUser;
}

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./*from  w  ww .j  a  v  a 2s  . co  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.google.gwt.visualization.sample.hellovisualization.client.VisualizationDemo.java

License:Apache License

/**
 * Creates a pie chart visualization./*from w  w  w. j  av  a  2 s .  c o  m*/
 *
 * @return panel with pie chart.
 */
private Widget createPieChart() {
    /* create a datatable */
    DataTable data = DataTable.create();
    data.addColumn(ColumnType.STRING, "Task");
    data.addColumn(ColumnType.NUMBER, "Hours per Day");
    data.addRows(5);
    data.setValue(0, 0, "Work");
    data.setValue(0, 1, 11);
    data.setValue(1, 0, "Eat");
    data.setValue(1, 1, 2);
    data.setValue(2, 0, "Commute");
    data.setValue(2, 1, 2);
    data.setValue(3, 0, "Watch TV");
    data.setValue(3, 1, 2);
    data.setValue(4, 0, "Sleep");
    data.setValue(4, 1, 7);

    /* create pie chart */

    PieOptions options = PieChart.createPieOptions();
    options.setWidth(400);
    options.setHeight(240);
    options.set3D(true);
    options.setTitle("My Daily Activities");
    return new PieChart(data, options);
}

From source file:com.google.gwt.visualization.sample.visualizationshowcase.client.AnnotatedDemo.java

License:Apache License

@SuppressWarnings("deprecation")
public AnnotatedDemo() {
    @SuppressWarnings("unused")
    int year, month, day;
    Options options = Options.create();/*from  w  w w. ja va2s  .c  o  m*/
    options.setDisplayAnnotations(true);

    DataTable data = DataTable.create();
    data.addColumn(ColumnType.DATE, "Date");
    data.addColumn(ColumnType.NUMBER, "Sold Pencils");
    data.addColumn(ColumnType.STRING, "title1");
    data.addColumn(ColumnType.STRING, "text1");
    data.addColumn(ColumnType.NUMBER, "Sold Pens");
    data.addColumn(ColumnType.STRING, "title2");
    data.addColumn(ColumnType.STRING, "text2");
    data.addRows(6);
    try {
        data.setValue(0, 0, new Date(year = 2008 - 1900, month = 1, day = 1));
        data.setValue(1, 0, new Date(year = 2008 - 1900, month = 1, day = 2));
        data.setValue(2, 0, new Date(year = 2008 - 1900, month = 1, day = 3));
        data.setValue(3, 0, new Date(year = 2008 - 1900, month = 1, day = 4));
        data.setValue(4, 0, new Date(year = 2008 - 1900, month = 1, day = 5));
        data.setValue(5, 0, new Date(year = 2008 - 1900, month = 1, day = 6));
    } catch (JavaScriptException ex) {
        GWT.log("Error creating data table - Date bug on mac?", ex);
    }
    data.setValue(0, 1, 30000);
    data.setValue(0, 4, 40645);
    data.setValue(1, 1, 14045);
    data.setValue(1, 4, 20374);
    data.setValue(2, 1, 55022);
    data.setValue(2, 4, 50766);
    data.setValue(3, 1, 75284);
    data.setValue(3, 4, 14334);
    data.setValue(3, 5, "Out of Stock");
    data.setValue(3, 6, "Ran out of stock on pens at 4pm");
    data.setValue(4, 1, 41476);
    data.setValue(4, 2, "Bought 200k pens");
    data.setValue(4, 4, 66467);
    data.setValue(5, 1, 33322);
    data.setValue(5, 4, 39463);

    status.setText("'Ready' event was not yet fired");
    chart = new AnnotatedTimeLine(data, options, "700px", "240px");

    widget.add(chart);
    widget.add(status);
    widget.add(rangeStatus);

    addHandlers();
}

From source file:com.google.gwt.visualization.sample.visualizationshowcase.client.GeoDemo.java

License:Apache License

public Widget getWidget() {
    final Options options = Options.create();
    options.setDataMode(GeoMap.DataMode.REGIONS);
    options.setHeight(300);/*from   w  w  w  . j  a v a 2s.com*/
    options.setWidth(450);
    options.setShowLegend(false);
    options.setColors(0xFF8747, 0xFFB581, 0xc06000);
    options.setRegion("world");

    final DataTable dataTable = DataTable.create();
    dataTable.addRows(7);
    dataTable.addColumn(ColumnType.STRING, "ADDRESS", "address");
    dataTable.setValue(0, 0, "Israel");
    dataTable.setValue(1, 0, "United States");
    dataTable.setValue(2, 0, "Germany");
    dataTable.setValue(3, 0, "Brazil");
    dataTable.setValue(4, 0, "Canada");
    dataTable.setValue(5, 0, "France");
    dataTable.setValue(6, 0, "RU");

    final GeoMap geo = new GeoMap(dataTable, options);
    return geo;
}

From source file:com.google.gwt.visualization.sample.visualizationshowcase.client.ImageDemo.java

License:Apache License

public ImageDemo() {
    ImageChart.Options options = ImageChart.Options.create();

    options.set("cht", "rs");
    options.set("chco", "00ff00,ff00ff");
    options.set("chg", "25.0,25.0,4.0,4.0");
    options.set("chm", "B,FF000080,0,1.0,5.0|B,FF990080,1,1.0,5.0");
    options.set("chls", "2,1,0|2,5,5");

    DataTable dataTable = DataTable.create();
    dataTable.addColumn(ColumnType.STRING);
    dataTable.addColumn(ColumnType.NUMBER);
    dataTable.addColumn(ColumnType.NUMBER);
    dataTable.addRows(8);

    char pi = '\u03C0';
    dataTable.setValue(0, 0, "0");
    dataTable.setValue(1, 0, pi + "/4");
    dataTable.setValue(2, 0, pi + "/2");
    dataTable.setValue(3, 0, "3" + pi + "/4");
    dataTable.setValue(4, 0, "" + pi);
    dataTable.setValue(5, 0, "5" + pi + "/4");
    dataTable.setValue(6, 0, "3" + pi + "/2");
    dataTable.setValue(7, 0, "7" + pi + "/4");

    dataTable.setValue(0, 1, 10);// w ww .j  a va 2  s  .  c  om
    dataTable.setValue(1, 1, 20);
    dataTable.setValue(2, 1, 30);
    dataTable.setValue(3, 1, 40);
    dataTable.setValue(4, 1, 50);
    dataTable.setValue(5, 1, 60);
    dataTable.setValue(6, 1, 70);
    dataTable.setValue(7, 1, 80);

    dataTable.setValue(0, 2, 100);
    dataTable.setValue(1, 2, 80);
    dataTable.setValue(2, 2, 60);
    dataTable.setValue(3, 2, 30);
    dataTable.setValue(4, 2, 25);
    dataTable.setValue(5, 2, 20);
    dataTable.setValue(6, 2, 10);
    dataTable.setValue(7, 2, 5);

    widget = new ImageChart(dataTable, options);
}

From source file:com.google.gwt.visualization.sample.visualizationshowcase.client.IntensityDemo.java

License:Apache License

public IntensityDemo() {
    Options options = Options.create();/*from  ww  w. j a  va2s.c  om*/

    DataTable data = DataTable.create();
    data.addColumn(ColumnType.STRING, "", "Country");
    data.addColumn(ColumnType.NUMBER, "Population (mil)", "a");
    data.addColumn(ColumnType.NUMBER, "Area (km2)", "b");
    data.addRows(5);
    data.setValue(0, 0, "CN");
    data.setValue(0, 1, 1324);
    data.setValue(0, 2, 9640821);
    data.setValue(1, 0, "IN");
    data.setValue(1, 1, 1133);
    data.setValue(1, 2, 3287263);
    data.setValue(2, 0, "US");
    data.setValue(2, 1, 304);
    data.setValue(2, 2, 9629091);
    data.setValue(3, 0, "ID");
    data.setValue(3, 1, 232);
    data.setValue(3, 2, 1904569);
    data.setValue(4, 0, "BR");
    data.setValue(4, 1, 187);
    data.setValue(4, 2, 8514877);

    widget = new IntensityMap(data, options);
}

From source file:com.google.gwt.visualization.sample.visualizationshowcase.client.MapDemo.java

License:Apache License

public MapDemo() {
    Options options = Options.create();// w w w  .  j a v  a  2  s  .  co  m
    options.setEnableScrollWheel(true);
    options.setLineColor("pink");
    options.setLineWidth(5);
    options.setMapType(MapVisualization.Type.HYBRID);
    options.setShowLine(true);
    options.setShowTip(true);

    DataTable data = DataTable.create();
    data.addColumn(ColumnType.NUMBER, "Lat");
    data.addColumn(ColumnType.NUMBER, "Lon");
    data.addColumn(ColumnType.STRING, "Name");
    data.addRows(4);
    data.setValue(0, 0, 37.4232);
    data.setValue(0, 1, -122.0853);
    data.setValue(0, 2, "Work");
    data.setValue(1, 0, 37.4289);
    data.setValue(1, 1, -122.1697);
    data.setValue(1, 2, "University");
    data.setValue(2, 0, 37.6153);
    data.setValue(2, 1, -122.3900);
    data.setValue(2, 2, "Airport");
    data.setValue(3, 0, 37.4422);
    data.setValue(3, 1, -122.1731);
    data.setValue(3, 2, "Shopping");

    widget = new MapVisualization(data, options, "400px", "300px");
}

From source file:com.google.gwt.visualization.sample.visualizationshowcase.client.MoneyDemo.java

License:Apache License

public MoneyDemo() {
    CommonChartOptions options = CommonChartOptions.create();

    options.setWidth(120);/*from   w  w  w.ja v a  2  s. co m*/
    options.setHeight(40);
    options.setTitle("Reveneues By Country");

    DataTable data = DataTable.create();

    data.addColumn(ColumnType.STRING, "Label");
    data.addColumn(ColumnType.NUMBER, "Value");
    data.addRows(4);
    data.setValue(0, 0, "France");
    data.setValue(1, 0, "Germany");
    data.setValue(2, 0, "USA");
    data.setValue(3, 0, "Poland");
    data.setCell(0, 1, 10, "$10,000", null);
    data.setCell(1, 1, 30, "$30,000", null);
    data.setCell(2, 1, 20, "$20,000", null);
    data.setCell(3, 1, 7.5, "$7,500", null);

    widget = new Visualization<AbstractDrawOptions>(data, options) {
        @Override
        protected native JavaScriptObject createJso(Element div) /*-{
                                                                 return new $wnd.PilesOfMoney(div);
                                                                 }-*/;
    };
}

From source file:com.google.gwt.visualization.sample.visualizationshowcase.client.MotionDemo.java

License:Apache License

@SuppressWarnings("deprecation")
public MotionDemo() {

    String protocol = Window.Location.getProtocol();
    if (protocol.startsWith("file")) {
        widget = new HTML("<font color=\"blue\"><i>Note: Protocol is: " + protocol
                + ".  Note that this visualization does not work when loading the HTML from "
                + "a local file. It works only when loading the HTML from a " + "web server. </i></font>");
        return;/*from   w w w  .  j  a  v a  2 s  . c  o m*/
    }

    @SuppressWarnings("unused")
    int year, month, day;

    Options options = Options.create();
    options.setHeight(300);
    options.setWidth(600);
    options.setState(STATE_STRING);
    DataTable data = DataTable.create();
    data.addRows(6);
    data.addColumn(ColumnType.STRING, "Fruit");
    data.addColumn(ColumnType.DATE, "Date");
    data.addColumn(ColumnType.NUMBER, "Sales");
    data.addColumn(ColumnType.NUMBER, "Expenses");
    data.addColumn(ColumnType.STRING, "Location");
    data.setValue(0, 0, "Apples");
    data.setValue(0, 2, 1000);
    data.setValue(0, 3, 300);
    data.setValue(0, 4, "East");
    data.setValue(1, 0, "Oranges");
    data.setValue(1, 2, 950);
    data.setValue(1, 3, 200);
    data.setValue(1, 4, "West");
    data.setValue(2, 0, "Bananas");
    data.setValue(2, 2, 300);
    data.setValue(2, 3, 250);
    data.setValue(2, 4, "West");
    data.setValue(3, 0, "Apples");
    data.setValue(3, 2, 1200);
    data.setValue(3, 3, 400);
    data.setValue(3, 4, "East");
    data.setValue(4, 0, "Oranges");
    data.setValue(4, 2, 900);
    data.setValue(4, 3, 150);
    data.setValue(4, 4, "West");
    data.setValue(5, 0, "Bananas");
    data.setValue(5, 2, 788);
    data.setValue(5, 3, 617);
    data.setValue(5, 4, "West");

    try {
        data.setValue(0, 1, new Date(year = 1988 - 1900, month = 0, day = 1));
        data.setValue(1, 1, new Date(year = 1988 - 1900, month = 0, day = 1));
        data.setValue(2, 1, new Date(year = 1988 - 1900, month = 0, day = 1));
        data.setValue(3, 1, new Date(year = 1988 - 1900, month = 1, day = 1));
        data.setValue(4, 1, new Date(year = 1988 - 1900, month = 1, day = 1));
        data.setValue(5, 1, new Date(year = 1988 - 1900, month = 1, day = 1));
    } catch (JavaScriptException ex) {
        GWT.log("Error creating data table - Date bug on mac?", ex);
    }

    final MotionChart motionChart = new MotionChart(data, options);
    motionChart.addStateChangeHandler(new StateChangeHandler() {

        @Override
        public void onStateChange(StateChangeEvent event) {
            String result = motionChart.getState();
            GWT.log(result);
        }
    });

    widget = motionChart;

}