JFreeChart in VAadin 7.4.0

I am going to draw a jfreechart on the page, the project gets compiled successfully but the src of the chart is set to null. so no chart is drawn.

Here is the source code:

package sh2.ebs.mavenproject1;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.annotations.Widgetset;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import javax.servlet.annotation.WebServlet;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.vaadin.addon.JFreeChartWrapper;

/**
 *
 */
@Theme("mytheme")
@Widgetset("sh2.ebs.mavenproject1.MyAppWidgetset")
public class MyUI extends UI {

    @Override
    protected void init(VaadinRequest vaadinRequest) {
        final VerticalLayout layout = new VerticalLayout();
        layout.setMargin(true);
        setContent(layout);
       
         XYSeries series = new XYSeries("Sprint 1");
        series.add(0, 165);
        series.add(1, 150);
        series.add(2, 130);

        XYSeriesCollection dataset = new XYSeriesCollection();
        dataset.addSeries(series);
        // Generate the graph
        JFreeChart chart = ChartFactory.createXYLineChart("Burn Down Chart", // Title
                "days", // x-axis Label
                "Esimated Effort", // y-axis Label
                dataset, // Dataset
                PlotOrientation.VERTICAL, // Plot Orientation
                true, // Show Legend
                true, // Use tooltips
                false // Configure chart to generate URLs?
                );
        JFreeChartWrapper wrapper = new JFreeChartWrapper(chart, JFreeChartWrapper.RenderingMode.PNG);
        
        layout.addComponent(wrapper);
    }

    @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
    @VaadinServletConfiguration(ui = MyUI.class, productionMode = false)
    public static class MyUIServlet extends VaadinServlet {
    }
}

It does not work with JFreeChartWrapper.RenderingMode.SVG either.

Just to note, the source code related to creating the chart is not mine.
I just used it as an example to run the jfreechartwrapper add-on.

Hi,

There is a regression in Vaadin since 7.3.9, that still hasn’t been solved. See
this thread
, it also has a workaround.

cheers,
matti

Thanks :slight_smile:

Using your workaround it works fine with 7.4.0

I didn’t surpeised when I saw your workaround since I had previously checked the page’s source code in the browser and faced with this

<img src="null" style="width: 809px; height: 500px;">