- GWT Google Charts Tutorial
- GWT Google Charts - Home
- GWT Google Charts - Overview
- Environment Setup
- Configuration Syntax
- GWT Google Charts - Area Charts
- GWT Google Charts - Bar Charts
- GWT Google Charts - Bubble Charts
- GWT Google Charts - Candlestick
- GWT Google Charts - Column Charts
- GWT Google Charts - Combination
- GWT Google Charts - Histogram
- GWT Google Charts - Line Charts
- GWT Google Charts - Maps
- GWT Google Charts - Organization
- GWT Google Charts - Pie Charts
- GWT Google Charts - Sankey Charts
- GWT Google Charts - Scatter Chart
- GWT Google Charts - Stepped Area
- GWT Google Charts - Table Chart
- GWT Google Charts - TreeMap Chart
- GWT Google Charts Resources
- GWT Google Charts - Quick Guide
- GWT Google Charts - Resources
- GWT Google Charts - Discussion
Sankey Charts with Multiple levels
Following is an example of a SanKey Chart with multiple levels.
We have already seen the configurations used to draw a chart in Google Charts Configuration Syntax chapter. Now, let us see an example of a SanKey Chart with multiple levels.
Configurations
We've used Sankey class to show a Sankey chart with multiple levels.
Sankey chart = new Sankey();
Example
HelloWorld.java
package com.tutorialspoint.client; import com.google.gwt.core.client.EntryPoint; import com.google.gwt.user.client.ui.RootPanel; import com.googlecode.gwt.charts.client.ChartLoader; import com.googlecode.gwt.charts.client.ChartPackage; import com.googlecode.gwt.charts.client.ColumnType; import com.googlecode.gwt.charts.client.DataTable; import com.googlecode.gwt.charts.client.sankey.Sankey; public class HelloWorld implements EntryPoint { private Sankey chart; private void initialize() { ChartLoader chartLoader = new ChartLoader(ChartPackage.SANKEY); chartLoader.loadApi(new Runnable() { public void run() { // Create and attach the chart chart = new Sankey(); RootPanel.get().add(chart); draw(); } }); } private void draw() { // Prepare the data DataTable data = DataTable.create(); data.addColumn(ColumnType.STRING, "From"); data.addColumn(ColumnType.STRING, "To"); data.addColumn(ColumnType.NUMBER, "Weight"); data.addRow("Brazil","Portugal",5); data.addRow("Brazil","France",1 ); data.addRow("Brazil","Spain",1 ); data.addRow("Brazil","England",1 ); data.addRow("Canada","Portugal",1 ); data.addRow("Canada","France",5 ); data.addRow("Canada","England",1 ); data.addRow("Mexico","Portugal",1 ); data.addRow("Mexico","France",1 ); data.addRow("Mexico","Spain",5 ); data.addRow("Mexico","England",1 ); data.addRow("USA","Portugal",1 ); data.addRow("USA","France",1 ); data.addRow("USA","Spain",1 ); data.addRow("USA","England",5); data.addRow("Portugal","Angola", 2 ); data.addRow("Portugal","Senegal", 1 ); data.addRow("Portugal", "Morocco", 1 ); data.addRow("Portugal","South Africa", 3 ); // Draw the chart chart.draw(data); chart.setWidth("400px"); chart.setHeight("400px"); } public void onModuleLoad() { initialize(); } }
Result
Verify the result.
gwt_googlecharts_sankey_charts.htm
Advertisements