Not able to control y-axis min-/max-values in Vaadin Charts

I have a simple chart implementation where I need to control the y-axis min and max values. I have added calls to Axis.setMin() and Axis.setMax(), but the displayed min / max values seems to be a bit random.

I have provided a complete example to demonstrate this. All you need to do is:

  1. Download the attached file (vaadin-charts-dashboard.tgz)
  2. tar xvfz vaadin-charts-dashboard.tgz
  3. cd vaadin-charts-dashboard
  4. mvn clean install
  5. mvn jetty:run
  6. localhost:8080/dashboard (in browser)

I have tested 3 scenarios (with reference to the Dashboard class shown below):

  1. Only ‘Chart 1’ added to vertical layout: OK, with min/max shown as 0/22 respectively
  2. Only ‘Chart 2’ added to vertical layout: NOK, with min/max shown as 0/24 respectively (instead of the specified 1/23)
  3. Both charts added to vertical layout: NOK, with min/max shown as 0/25 respectively for both charts

Any clues on what is going on here?


public class Dashboard extends UI {

	@Override
	protected void init(VaadinRequest vaadinRequest) {
		setSizeFull();

		VerticalLayout verticalLayout = new VerticalLayout();
		verticalLayout.setSizeFull();
		verticalLayout.setSpacing(true);

		// Create first chart
		SampleChart sampleChart1 = new SampleChart("Chart 1", 0d, 22d);
		verticalLayout.addComponent(sampleChart1);

		// Create second chart
		SampleChart sampleChart2 = new SampleChart("Chart 2", 1d, 23d);
		verticalLayout.addComponent(sampleChart2);

		setContent(verticalLayout);
	}

	class SampleChart extends Chart {
		public SampleChart(final String chartTitle, final Double axisMinValue, final Double axisMaxValue) {

			setSizeFull();

			// Set chart type
			Configuration configuration = new Configuration();
			configuration.getChart().setType(ChartType.LINE);

			// Set chart title
			configuration.getTitle().setText(chartTitle);

			// Set type for x-axis
			configuration.getxAxis().setType(AxisType.DATETIME);

			// Set min / max y-axis value
			Axis yAxis = configuration.getyAxis();
			yAxis.setMin(axisMinValue);
			yAxis.setMax(axisMaxValue);

			// Create sample series
			DataSeries chartSeries = new DataSeries();

			// Add series to chart
			configuration.addSeries(chartSeries);

			drawChart(configuration);
		}
	}
}

12946.tgz (10.9 KB)