JfreeChartWrapper not displaying chart

This looks like a regression in Vaadin core to me. A workaround is to call markAsDirty for the component after it is attached. Quick fix:

        JFreeChartWrapper jFreeChartWrapper = new JFreeChartWrapper(chart) {

            @Override
            public void attach() {
                super.attach();
                markAsDirty();
            }
            
        };

Hi Matti,

I tried your suggestion (Vaadin 7.3.10) but it doesn’t help wether in my application nor in the test case of the addon. With Vaadin 7.3.8 both are working as expected.

Yes, my bad, I made a mistake when searching for a workaround. Try this one:

        JFreeChartWrapper jFreeChartWrapper = new JFreeChartWrapper(jfreechart) {

                    @Override
                    public void attach() {
                        super.attach();
                        setResource("src", getSource());
                    }
                };

Great!
Now it works with Vaadin 7.3.10.

Thanks again

Perfect solution also for me. !!
Thanks

Thanks you for this !

Work like charmed… :slight_smile:
Thank you…

Thank you. :slight_smile:

I use vaadin 7.5.8 and jfreechartwrapper 3.0.2 and didn’t see the chart too. Has anybody an idea?
Or which versions must I use that it works?

package com.app.UI;

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;

import com.vaadin.annotations.Theme;
import com.vaadin.annotations.Title;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;

@Theme(“mytheme”)
@Title(“TP_Mon”)

public class TP_Mon extends UI {

@Override
protected void init(VaadinRequest vaadinRequest) {

    VerticalLayout layout = new VerticalLayout(); // Gesamtlayout Haupt

    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) {
        @Override
        public void attach() {
            super.attach();
            markAsDirty();
        }
    };
    layout.addComponent(wrapper);
    setContent(layout);
}

@WebServlet(urlPatterns = "/*", name = "TP_MonServlet", asyncSupported = true)
@VaadinServletConfiguration(ui = TP_Mon.class, productionMode = false, widgetset = "com.app.gwt.AppWidgetSet")
public static class TP_MonServlet extends VaadinServlet {
}

}

News???

Thanks! Works as expected with vaadin
7.6.5
.

Hint
: Do use the second workaround!

thanks a lot.

Hi,

I guess the regression will never be fixed by the core team so I added the workaround to the component in version 3.0.3

cheers,
matti

I have a problem which I’m not sure is it related to this one but lets try.

I have a CssLayout where I have ja table and a JFreeChartWrapper (displaying a pie chart).
Everything is working fine when I’m testing and running the application on Jetty, but on a server (tomcat) I get an Internal Error when displaying the view where the chart is placed. If I use example a label instead of JFreeChartWrapper, everything is OK.

Have anyone else same kind of experience? What can I do to debug the problem, because I don’t get any detailed information ebout the Internal Error?

I’m using latest version from vaadin and jfreechartwrapper.

Sounds quite weird if there is nothing on the server log. If you could share the project creating your war file it might be easier to give some hints to get this resolved.

cheers,
matti

Please help! I am using vaadin client 7.7.3, jfreechartwrapper 3.0.4 and jfreechart 1.0.19 - using the second workaround, nothing appears on the page. Without it, it seems that there is an empty space created for it but no chart appeared. Should I use vaadin 7.6.5?

Thank you!

7.7.16 is the latest in Vaadin 7 series. I think you should use that. IIRC, with 3.0.4 you shouldn’t need any workarounds. But in general, it is quite hard to help you with these details. It would help a lot if you report any errors you have, report the server and browser version you use and create a reduced test case.

Check my recent blog entry:
https://vaadin.com/blog/5-tips-to-get-your-issue-solved-quicker-in-open-source-projects

cheers,
matti

It doesn’t generate any errors in Eclipse that i can see. I run Tomcat locally. I am using Chrome browser version 71.0.3578.98 (Official Build) (64-bit) on a Windows machine. What would you need in terms of test cases? Forgot to mention, I am using the vaadin valo theme as well.

relevant code:

	public VerticalLayout creditGraphLayout(){
		VerticalLayout layout = new VerticalLayout();
		
	    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
	    dataset.setValue(48.0, "2018", "Q1");
	    dataset.setValue(40.0, "2019", "Q1");
	    dataset.setValue(28.0, "2018", "Q2");
	    dataset.setValue(28.0, "2019", "Q2");
	    dataset.setValue(39.0, "2018", "Q3");
	    dataset.setValue(60.0, "2019", "Q3");
	    dataset.setValue(40.0, "2018", "Q4");
	    dataset.setValue(29.0, "2019", "Q4");
	    
	    
	    JFreeChart chart = ChartFactory.createBarChart(
	        "Physical Activity", 
	        "Quarter",
	        "Points",
	        dataset,
	        PlotOrientation.VERTICAL,
	        true, 
	        true,
	        false
	    );
	    
	   
	    JFreeChartWrapper wrapper = new JFreeChartWrapper(chart);
	    /*{

	    	@Override
            public void attach() {
                super.attach();
                Resource r = getSource();
                setResource("src", r);
            }
	    };*/
	    
	    layout.addComponent(wrapper);
	    //System.out.println("wrapper: " + wrapper);
		
		return layout;
	}
	
	/// calling the method when building a page in the same class
	
	addComponent(creditGraphLayout());

That’s what I have so far. I am trying to add this Jfreechart to an existing project. It seems pretty straight forward but it is not displaying. In addition, I have run this separately outside Vaadin and it generated the graph.

Hi,

Can you try with this reduced case. It uses your jfreechart configuration and it seems to work just fine for me. If it works, you’ll need to look for possible differences with your project that might cause this. Otherwise we’ll need more hints to tackle this, such as JDK version and Windows version etc.

cheers,
matti

17501690.zip (31.7 KB)
17501693.jpg

Thank you for your prompt help. Apparently it is not the wrapper issue, it is the x-frame-options that needs to be configured in our config.