// Create a callback to be called when the visualization API
// has been loaded.
Runnable onLoadCallback = new Runnable() {
public void run() {
// Create nodes table with some data
DataTable nodes = DataTable.create();
nodes.addColumn(DataTable.ColumnType.NUMBER, "id");
nodes.addColumn(DataTable.ColumnType.STRING, "text");
nodes.addRow();
int i = 0;
nodes.setValue(i, 0, 1);
nodes.setValue(i, 1, "Node 1");
nodes.addRow();
i++;
nodes.setValue(i, 0, 2);
nodes.setValue(i, 1, "Node 2");
nodes.addRow();
i++;
nodes.setValue(i, 0, 3);
nodes.setValue(i, 1, "Node 3");
// Create links table with some data
DataTable links = DataTable.create();
links.addColumn(DataTable.ColumnType.NUMBER, "from");
links.addColumn(DataTable.ColumnType.NUMBER, "to");
links.addRow();
i = 0;
links.setValue(i, 0, 1);
links.setValue(i, 1, 2);
links.addRow();
i++;
links.setValue(i, 0, 1);
links.setValue(i, 1, 3);
links.addRow();
i++;
links.setValue(i, 0, 2);
links.setValue(i, 1, 3);
// Create links table with some data
DataTable packages = DataTable.create();
packages.addColumn(DataTable.ColumnType.NUMBER, "from");
packages.addColumn(DataTable.ColumnType.NUMBER, "to");
packages.addColumn(DataTable.ColumnType.NUMBER, "duration");
packages.addRow();
i = 0;
packages.setValue(i, 0, 1);
packages.setValue(i, 1, 2);
packages.setValue(i, 2, 5);
packages.addRow();
i++;
packages.setValue(i, 0, 1);
packages.setValue(i, 1, 3);
packages.setValue(i, 2, 3);
packages.addRow();
i++;
packages.setValue(i, 0, 2);
packages.setValue(i, 1, 3);
packages.setValue(i, 2, 1);
// Create options
Network.Options options = Network.Options.create();
options.setWidth("300px");
options.setHeight("300px");