Example usage for com.google.gwt.visualization.client.visualizations AnnotatedTimeLine PACKAGE

List of usage examples for com.google.gwt.visualization.client.visualizations AnnotatedTimeLine PACKAGE

Introduction

In this page you can find the example usage for com.google.gwt.visualization.client.visualizations AnnotatedTimeLine PACKAGE.

Prototype

String PACKAGE

To view the source code for com.google.gwt.visualization.client.visualizations AnnotatedTimeLine PACKAGE.

Click Source Link

Usage

From source file:com.facebook.tsdb.tsdash.client.plot.InteractivePlot.java

License:Apache License

@Override
public void render(final Command onRendered) {
    if (!APILoaded) {
        GWT.log("Loading the API...");
        VisualizationUtils.loadVisualizationApi(new Runnable() {
            @Override//from ww w .  j  av  a  2  s. c o  m
            public void run() {
                APILoaded = true;
                GWT.log("API loaded");
                render(onRendered);
            }
        }, AnnotatedTimeLine.PACKAGE);
        return;
    }
    if (timeSeriesJSON == null) {
        GWT.log("cannot render: null data");
        return;
    }
    DataTable dataTable = DataTable.create(timeSeriesJSON.getJavaScriptObject());
    Widget w = (Widget) container;
    final AnnotatedTimeLine newChart = new AnnotatedTimeLine(dataTable, getChartOptions(),
            (w.getOffsetWidth() - 10) + "px", (w.getOffsetHeight() - 10) + "px");
    newChart.addReadyHandler(new ReadyHandler() {
        @Override
        public void onReady(ReadyEvent event) {
            endRender(newChart);
            onRendered.execute();
        }
    });
    startRender(newChart);
}

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

License:Apache License

public void onModuleLoad() {
    VisualizationUtils.loadVisualizationApi(new Runnable() {
        public void run() {
            final VerticalPanel vp = new VerticalPanel();
            vp.setSpacing(15);//from ww w  . j  ava2s.  c o  m
            RootPanel.get().add(vp);
            vp.add(new HTML("The following visualizations are included in the GWT "
                    + "Visualization API in the package "
                    + "<tt>com.google.gwt.visualization.client.visualizations</tt>.  "
                    + "For a full listing of visualizations available in GWT, see <a href=" + '"'
                    + "http://code.google.com/apis/visualization/documentation/gallery.html" + '"'
                    + ">the Google Visualization API</a>."));
            LeftTabPanel tabby = new LeftTabPanel();
            vp.add(tabby);
            AnnotatedDemo annotatedWidget = new AnnotatedDemo();
            tabby.add(annotatedWidget, "AnnotatedTimeLine");
            tabby.add(new AreaDemo(), "AreaChart");
            tabby.add(new ImageAreaDemo(), "AreaChart (Image)");
            tabby.add(new BarDemo(), "BarChart");
            tabby.add(new ImageBarDemo(), "BarChart (Image)");
            tabby.add(new ColumnDemo(), "ColumnChart");
            tabby.add(new GaugeDemo(), "Gauge");
            tabby.add(new GeoDemo(), "GeoMap");
            tabby.add(new IntensityDemo(), "IntensityMap");
            tabby.add(new LineDemo(), "LineChart");
            tabby.add(new ImageLineDemo(), "LineChart (Image)");
            tabby.add(new MapDemo(), "Map");
            tabby.add(new MoneyDemo(), "MoneyChart");
            tabby.add(new MotionDemo(), "MotionChart");
            tabby.add(new OrgDemo(), "OrgChart");
            tabby.add(new PieDemo(), "PieChart");
            tabby.add(new ImagePieDemo(), "PieChart (Image)");
            tabby.add(new ImageDemo(), "RadarChart (Image)");
            tabby.add(new ScatterDemo(), "ScatterChart");
            tabby.add(new SparklineDemo(), "Sparkline (Image)");
            tabby.add(new TableDemo(), "Table");
            tabby.add(new ToolbarDemo(), "Toolbar");
            tabby.setWidget(annotatedWidget);
        }
    }, AnnotatedTimeLine.PACKAGE, CoreChart.PACKAGE, Gauge.PACKAGE, GeoMap.PACKAGE, ImageChart.PACKAGE,
            ImageLineChart.PACKAGE, ImageAreaChart.PACKAGE, ImageBarChart.PACKAGE, ImagePieChart.PACKAGE,
            IntensityMap.PACKAGE, MapVisualization.PACKAGE, MotionChart.PACKAGE, OrgChart.PACKAGE,
            Table.PACKAGE, ImageSparklineChart.PACKAGE);
}

From source file:com.scalagent.appli.client.Application.java

License:Open Source License

/**
 * This is the entry point method.//from ww  w . j av  a2  s .  c  om
 */
public void onModuleLoad2() {

    Runnable onLoadCallback = new Runnable() {
        public void run() {

            serviceAsync = GWT.create(BaseRPCService.class);

            eventBus = new SimpleEventBus();
            serviceCache = new RPCServiceCacheClient(serviceAsync, eventBus, -1);

            ServerPresenter serverPresenter = new ServerPresenter(serviceAsync, eventBus, serviceCache);
            LoginPresenter loginPresenter = new LoginPresenter(serviceAsync, eventBus, serviceCache);
            TopicListPresenter topicPresenter = new TopicListPresenter(serviceAsync, eventBus, serviceCache);
            QueueListPresenter queuePresenter = new QueueListPresenter(serviceAsync, eventBus, serviceCache);
            UserListPresenter userPresenter = new UserListPresenter(serviceAsync, eventBus, serviceCache);
            SubscriptionListPresenter subscriptionPresenter = new SubscriptionListPresenter(serviceAsync,
                    eventBus, serviceCache);

            MainPresenter mainPresenter = new MainPresenter(serviceAsync, serviceCache, eventBus,
                    loginPresenter, serverPresenter, topicPresenter, queuePresenter, userPresenter,
                    subscriptionPresenter);

            eventBus.addHandler(SystemErrorEvent.TYPE, mainPresenter);
            eventBus.addHandler(QueueDetailClickEvent.TYPE, mainPresenter);
            eventBus.addHandler(UserDetailClickEvent.TYPE, mainPresenter);
            eventBus.addHandler(SubscriptionDetailClickEvent.TYPE, mainPresenter);
            eventBus.addHandler(LoginValidEvent.TYPE, mainPresenter);

            eventBus.addHandler(UpdateCompleteEvent.TYPE, serverPresenter);

            eventBus.addHandler(NewTopicEvent.TYPE, topicPresenter);
            eventBus.addHandler(DeletedTopicEvent.TYPE, topicPresenter);
            eventBus.addHandler(UpdatedTopicEvent.TYPE, topicPresenter);
            eventBus.addHandler(UpdateCompleteEvent.TYPE, topicPresenter);

            eventBus.addHandler(NewQueueEvent.TYPE, queuePresenter);
            eventBus.addHandler(DeletedQueueEvent.TYPE, queuePresenter);
            eventBus.addHandler(UpdatedQueueEvent.TYPE, queuePresenter);
            eventBus.addHandler(UpdateCompleteEvent.TYPE, queuePresenter);

            eventBus.addHandler(NewUserEvent.TYPE, userPresenter);
            eventBus.addHandler(DeletedUserEvent.TYPE, userPresenter);
            eventBus.addHandler(UpdatedUserEvent.TYPE, userPresenter);
            eventBus.addHandler(UpdateCompleteEvent.TYPE, userPresenter);

            eventBus.addHandler(NewSubscriptionEvent.TYPE, subscriptionPresenter);
            eventBus.addHandler(DeletedSubscriptionEvent.TYPE, subscriptionPresenter);
            eventBus.addHandler(UpdatedSubscriptionEvent.TYPE, subscriptionPresenter);
            eventBus.addHandler(UpdateCompleteEvent.TYPE, subscriptionPresenter);

            MainWidget mWidget = mainPresenter.getWidget();
            Canvas mainCanvas = (Canvas) mWidget.asWidget();

            mainCanvas.draw();
        }
    };
    VisualizationUtils.loadVisualizationApi(onLoadCallback, AnnotatedTimeLine.PACKAGE);
}

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

License:Apache License

/**
 * This is the entry point method./*www.j  a v a2  s . c o  m*/
 */
public void onModuleLoad() {
    VisualizationUtils.loadVisualizationApi(new Runnable() {
        public void run() {
            loadUi();
        }
    }, ColumnChart.PACKAGE, AnnotatedTimeLine.PACKAGE);
}

From source file:net.officefloor.demo.stocks.client.StockGraphWidget.java

License:Open Source License

/**
 * Initiate./*  w  w w. j av  a2  s  .  c o  m*/
 * 
 * @param historyPeriod
 *            Time in milliseconds to display history of prices.
 * @param redrawPeriod
 *            Time in milliseconds to allow before complete redraw of the
 *            graph.
 * @param width
 *            Width.
 * @param height
 *            Height.
 * @param stocks
 *            {@link Stock} instances to graph.
 */
public StockGraphWidget(final long historyPeriod, final long redrawPeriod, final String width,
        final String height, Stock... stocks) {

    // Create sorted copy of stocks
    final Stock[] orderedStocks = new Stock[stocks.length];
    for (int i = 0; i < orderedStocks.length; i++) {
        orderedStocks[i] = stocks[i];
    }
    Arrays.sort(orderedStocks, new Comparator<Stock>() {
        @Override
        public int compare(Stock a, Stock b) {
            return String.CASE_INSENSITIVE_ORDER.compare(a.getName(), b.getName());
        }
    });

    // Load the chart visualisation
    Runnable loadGraph = new Runnable() {
        @Override
        public void run() {

            // Provide tab panel for graphs
            TabPanel tab = new TabPanel();
            tab.setWidth(width);
            tab.getTabBar().setWidth(width);
            tab.getDeckPanel().setWidth(width);
            StockGraphWidget.this.add(tab);

            // Load each graph onto a tab
            final StockGraph[] graphs = new StockGraph[orderedStocks.length];
            for (int i = 0; i < orderedStocks.length; i++) {
                Stock stock = orderedStocks[i];

                // Create the stock graph
                StockGraph graph = new StockGraph(stock, historyPeriod, redrawPeriod, width, height);
                graphs[i] = graph;

                // Add the stock graph
                tab.add(graph.getChart(), stock.getName());
            }

            // Provide the selection handler
            tab.addSelectionHandler(new SelectionHandler<Integer>() {
                @Override
                public void onSelection(SelectionEvent<Integer> event) {

                    // Unselect all graphs
                    for (StockGraph graph : graphs) {
                        graph.setSelected(false);
                    }

                    // Select the graph for the tab
                    Integer tabIndex = event.getSelectedItem();
                    graphs[tabIndex.intValue()].setSelected(true);
                }
            });

            // Display first tab selected (also sets up graph)
            tab.selectTab(0);
        }
    };
    VisualizationUtils.loadVisualizationApi(loadGraph, AnnotatedTimeLine.PACKAGE);
}

From source file:org.opennms.ipv6.summary.gui.client.Application.java

License:Open Source License

/**
 * This is the entry point method./*ww  w . java 2  s . c  o m*/
 */
public void onModuleLoad() {
    m_chartService = new DefaultChartService();

    Image img = new Image();
    img.setUrl("../images/logo.png");
    img.getElement().getStyle().setPaddingTop(14, Unit.PX);
    img.getElement().getStyle().setPaddingLeft(14, Unit.PX);

    FlowPanel header = new FlowPanel();
    header.getElement().setId("header");
    header.add(img);

    final DockLayoutPanel dockLayoutPanel = new DockLayoutPanel(Unit.PX);
    dockLayoutPanel.addNorth(header, 75.00);
    RootLayoutPanel.get().add(dockLayoutPanel);

    m_nav = new Navigation();
    m_nav.addLocationUpdateEventHandler(this);
    m_nav.addHostUpdateEventHandler(this);

    m_flowPanel = new FlowPanel();

    Runnable timelineCallback = new Runnable() {

        public void run() {

            m_chartService.getAllLocationsAvailability(new RequestCallback() {

                @Override
                public void onResponseReceived(Request request, Response response) {
                    if (response.getStatusCode() == 200) {
                        m_timeline = new AnnotatedTimeLine(
                                ChartUtils.convertJSONToDataTable(response.getText()), createTimelineOptions(),
                                "440px", "250px");

                        m_flowPanel.add(m_timeline);
                        m_flowPanel.add(m_nav);
                        dockLayoutPanel.add(m_flowPanel);
                    }
                }

                @Override
                public void onError(Request request, Throwable exception) {
                    Window.alert("Error Initializing Chart");

                }
            });

        }

    };

    VisualizationUtils.loadVisualizationApi(timelineCallback, AnnotatedTimeLine.PACKAGE);
    initializeNav();
}

From source file:org.sonar.plugins.timeline.client.GwtTimeline.java

License:Open Source License

private void loadVisualizationApi() {
    Runnable onLoadCallback = new Runnable() {
        public void run() {
            render();//from  w  ww  . j a va2s  .  c o m
            loadTimeline();
        }
    };
    VisualizationUtils.loadVisualizationApi(onLoadCallback, AnnotatedTimeLine.PACKAGE);
}