VisualizationsForVaadin not showing problems


VisualizationsForVaadin


If I add the visualization straight to the layout of a subwindow, unless I pinch resize the subwindow manually from the clientside causing a refresh, the visualization doesn’t show (just calling a refresh from the serverside doesn’t work:

package com.example.vaadintest;

import org.vaadin.vaadinvisualizations.BarChartImage;

import com.vaadin.Application;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;

public class VaadintestApplication extends Application {
	@Override
	public void init() {
		final Window mainWindow = new Window("Vaadintest Application");
		setMainWindow(mainWindow);

		Button button = new Button("aso;dfn;aosjdfn");
		button.addListener(new Button.ClickListener() {

			public void buttonClick(ClickEvent event) {
				// Add a Bar Chart Image
				BarChartImage bc = new BarChartImage();

				bc.addXAxisLabel("Year");
				bc.addBar("Expenses");
				bc.addBar("Sales");
				bc.add("2004", new double[] { 1000, 400 });
				bc.add("2005", new double[] { 1170, 460 });
				bc.add("2006", new double[] { 860, 580 });
				bc.add("2007", new double[] { 1030, 540 });
				bc.setSizeFull();

				Window window = new Window();
				window.setWidth("640px");
				window.setHeight("480px");
				// Panel panel = new Panel();
				// panel.setSizeFull();
				// panel.setHeight("100%");
				// panel.addComponent(bc);
				// window.addComponent(panel);
				mainWindow.addWindow(window);
				window.addComponent(bc);
				// ((VerticalLayout) window.getContent()).setExpandRatio(panel,
				// 1);
				window.requestRepaint();
			}
		});

		mainWindow.addComponent(button);
	}

}

[b]

If I add one to a panel on a window, the panel doesn’t extend in height to the full height of the subwindow, and the visualization doesn’t display:
[/b]

package com.example.vaadintest;

import org.vaadin.vaadinvisualizations.BarChartImage;

import com.vaadin.Application;
import com.vaadin.ui.*;
import com.vaadin.ui.Button.ClickEvent;

public class VaadintestApplication extends Application {
	@Override
	public void init() {
		final Window mainWindow = new Window("Vaadintest Application");
		setMainWindow(mainWindow);

		Button button = new Button("aso;dfn;aosjdfn");
		button.addListener(new Button.ClickListener() {

			public void buttonClick(ClickEvent event) {
				// Add a Bar Chart Image
				BarChartImage bc = new BarChartImage();

				bc.addXAxisLabel("Year");
				bc.addBar("Expenses");
				bc.addBar("Sales");
				bc.add("2004", new double[] { 1000, 400 });
				bc.add("2005", new double[] { 1170, 460 });
				bc.add("2006", new double[] { 860, 580 });
				bc.add("2007", new double[] { 1030, 540 });
				bc.setSizeFull();

				Window window = new Window();
				window.setWidth("640px");
				window.setHeight("480px");
				Panel panel = new Panel();
				panel.setSizeFull();
				panel.setHeight("100%");
				panel.addComponent(bc);
				window.addComponent(panel);
				mainWindow.addWindow(window);
				((VerticalLayout) window.getContent()).setExpandRatio(panel, 1);
			}
		});

		mainWindow.addComponent(button);
	}

}


It would seem that the answer is setting the panel’s layout size to a constant is the answer:

package com.example.vaadintest;

import org.vaadin.vaadinvisualizations.BarChartImage;

import com.vaadin.Application;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Window;

public class VaadintestApplication extends Application {
	@Override
	public void init() {
		final Window mainWindow = new Window("Vaadintest Application");
		setMainWindow(mainWindow);

		Button button = new Button("aso;dfn;aosjdfn");
		button.addListener(new Button.ClickListener() {

			public void buttonClick(ClickEvent event) {
				// Add a Bar Chart Image
				BarChartImage bc = new BarChartImage();

				bc.addXAxisLabel("Year");
				bc.addBar("Expenses");
				bc.addBar("Sales");
				bc.add("2004", new double[] { 1000, 400 });
				bc.add("2005", new double[] { 1170, 460 });
				bc.add("2006", new double[] { 860, 580 });
				bc.add("2007", new double[] { 1030, 540 });
				bc.setSizeFull();

				Window window = new Window();

				Panel panel = new Panel();
				panel.setScrollable(false);

				ComponentContainer layout = panel.getContent();
				layout.setWidth("640px");
				layout.setHeight("480px");
				panel.addComponent(bc);

				window.addComponent(panel);
				mainWindow.addWindow(window);
//				((VerticalLayout) window.getContent()).setExpandRatio(panel, 1);
			}
		});

		mainWindow.addComponent(button);
	}

}


Also true for the window’s layout:

package com.example.vaadintest;

import org.vaadin.vaadinvisualizations.BarChartImage;

import com.vaadin.Application;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Window;

public class VaadintestApplication extends Application {
	@Override
	public void init() {
		final Window mainWindow = new Window("Vaadintest Application");
		setMainWindow(mainWindow);

		Button button = new Button("aso;dfn;aosjdfn");
		button.addListener(new Button.ClickListener() {

			public void buttonClick(ClickEvent event) {
				// Add a Bar Chart Image
				BarChartImage bc = new BarChartImage();

				bc.addXAxisLabel("Year");
				bc.addBar("Expenses");
				bc.addBar("Sales");
				bc.add("2004", new double[] { 1000, 400 });
				bc.add("2005", new double[] { 1170, 460 });
				bc.add("2006", new double[] { 860, 580 });
				bc.add("2007", new double[] { 1030, 540 });
				bc.setSizeFull();

				Window window = new Window();

				ComponentContainer layout = window.getContent();
				layout.setWidth("600px");
				layout.setHeight("440px");

				window.addComponent(bc);
				mainWindow.addWindow(window);
			}
		});

		mainWindow.addComponent(button);
	}

}