Example usage for com.google.gwt.visualization.client AbstractDataTable getColumnLabel

List of usage examples for com.google.gwt.visualization.client AbstractDataTable getColumnLabel

Introduction

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

Prototype

public final native String getColumnLabel(int columnIndex) ;

Source Link

Usage

From source file:com.google.gwt.visualization.sample.customvisualization.client.CustomVisualization.java

License:Apache License

@Override
public void draw(AbstractDataTable dataTable, CustomVisualizationDrawOptions options) {
    grid.clear();/*from  ww  w.ja  va  2s  .  com*/
    // Apply the drawing options
    if (options != null) {
        grid.getElement().getStyle().setProperty("backgroundColor", options.getBackgroundColor());
    }

    for (int c = 0; c < dataTable.getNumberOfColumns(); c++) {
        grid.setHTML(0, c, "<b>" + dataTable.getColumnLabel(c) + "</b>");
    }

    for (int r = 0; r < dataTable.getNumberOfRows(); r++) {
        for (int c = 0; c < dataTable.getNumberOfColumns(); c++) {
            grid.setText(r + 1, c, dataTable.getFormattedValue(r, c));
        }
    }
    // handle selection
    grid.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            cell = grid.getCellForEvent(event);
            CustomVisualization.this.fireSelectionEvent();
        }
    });
}