labels overlap

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
junico
Posts: 2
Joined: Thu Jul 29, 2010 1:10 pm
antibot: No, of course not.

labels overlap

Post by junico » Thu Jul 29, 2010 2:29 pm

Hi
this is my first post on this forum
First thanks Dave and jfree chart team for the framework. :)

We have a servlet (deployed on weblogic 10.3) that generates charts based on a URL, and streams the image through the response OutputStream.
After somedays running, the charts start to get like in the images below:

Image

Image

Image

It appears the white labels are getting tiny and making the text to overlap.

and here are the charts when they are ok

Image

Image

Image

The problem is solved by reestarting the app server :roll:
I suspected the problem was about the streaming, and tried writing the image to disk and sending a redirect to another url that would get the image statically.
But it did'nt worked either, the images writen to disk already are the with the problem .
I could not reproduce the problem with jetty or tomcat, because I can't reproduce it locally even in weblogic.
As I said the problem appears randomly.
My Servlet has no shared state.
We use jrockit VM, I would say this is the real source of the problem, but believe me I really want the problem to be in my code lol

the code we use is this:

Code: Select all

                 JFreeChart chart = ChartFactory.createPieChart(title, data, false, true, false);

		final PiePlot plot = (PiePlot) chart.getPlot();
		
		PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} = {2}", new DecimalFormat("0"), new DecimalFormat("0.00%"));
		plot.setLabelGenerator(generator);
		Paint bgPaint = chart.getBackgroundPaint();
		plot.setLabelBackgroundPaint(bgPaint);

		plot.setDirection(Rotation.CLOCKWISE);
		plot.setStartAngle(270);

		Font ft = PiePlot.DEFAULT_LABEL_FONT;

		TextTitle textTitle = chart.getTitle();
		textTitle.setFont(ft.deriveFont(7));

		plot.setLabelFont(ft);
		Color backgoundGraph;
		backgoundGraph = new Color(243, 243, 243);
		chart.setBackgroundPaint(backgoundGraph);

 

Code: Select all

final JFreeChart chart = ChartFactory.createStackedBarChart(title, "", "%", dataset,
				PlotOrientation.VERTICAL, true, false, false); // chart
		 
		final CategoryPlot plot = chart.getCategoryPlot();

		final ValueAxis rangeAxis = plot.getRangeAxis();
		rangeAxis.setLowerMargin(0.15);
		rangeAxis.setUpperMargin(0.15);

		Font ft = rangeAxis.getTickLabelFont();

		CategoryAxis domainAxis = plot.getDomainAxis();
		domainAxis.setLabelFont(ft.deriveFont(7));
		domainAxis.setTickLabelFont(ft.deriveFont(7));

		rangeAxis.setLabelFont(ft.deriveFont(7));
		rangeAxis.setTickLabelFont(ft.deriveFont(7));

		LegendTitle legendTitle = chart.getLegend();
		legendTitle.setItemFont(ft.deriveFont(7));

		TextTitle textTitle = chart.getTitle();
		textTitle.setFont(ft.deriveFont(7));

		final CategoryItemRenderer renderer = plot.getRenderer();

		GradientPaint gp0;
		GradientPaint gp1;

		GradientPaint gp3;

		gp0 = new GradientPaint(0.0f, 0.0f, new Color(204, 0, 0), 0.0f, 0.0f, Color.red);

		gp1 = new GradientPaint(0.0f, 0.0f, new Color(255, 102, 0), 0.0f, 0.0f, Color.orange);

		gp3 = new GradientPaint(0.0f, 0.0f, new Color(0, 102, 0), 0.0f, 0.0f, new Color(0, 153, 51));

		renderer.setSeriesPaint(0, gp3);
		renderer.setSeriesPaint(1, gp1);
		renderer.setSeriesPaint(2, gp0);

		Color backgoundGraph;
		backgoundGraph = new Color(243, 243, 243);
		chart.setBackgroundPaint(backgoundGraph);

Code: Select all

                JFreeChart chart = ChartFactory.createBarChart(title, "", "", dataset, PlotOrientation.VERTICAL,
				true, true, false);

		CategoryPlot plot = chart.getCategoryPlot();
		NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

		Font ft = rangeAxis.getTickLabelFont();

		CategoryAxis domainAxis = plot.getDomainAxis();
		domainAxis.setLabelFont(ft.deriveFont(7));
		domainAxis.setTickLabelFont(ft.deriveFont(7));

		rangeAxis.setLabelFont(ft.deriveFont(7));
		rangeAxis.setTickLabelFont(ft.deriveFont(7));

		LegendTitle legendTitle = chart.getLegend();
		legendTitle.setItemFont(ft.deriveFont(7));

		TextTitle textTitle = chart.getTitle();
		textTitle.setFont(ft.deriveFont(7));

		BarRenderer renderer = (BarRenderer) plot.getRenderer();
		renderer.setDrawBarOutline(false);

		GradientPaint gp0;

		GradientPaint gp4;

		gp0 = new GradientPaint(0.0f, 0.0f, new Color(204, 0, 0), 0.0f, 0.0f, Color.red);
		gp4 = new GradientPaint(0.0f, 0.0f, new Color(0, 0, 153), 0.0f, 0.0f, new Color(0, 0, 204));

		renderer.setSeriesPaint(0, gp0);
		renderer.setSeriesPaint(1, gp4);

		Color backgoundGraph;
		backgoundGraph = new Color(243, 243, 243);
		chart.setBackgroundPaint(backgoundGraph);


any help is more than welcome
thanks
Victor

bksh
Posts: 1
Joined: Fri Jul 30, 2010 6:13 am
antibot: No, of course not.

Re: labels overlap

Post by bksh » Fri Jul 30, 2010 6:28 am

I am also facing the same issue :(.
Any solution is most welcome.
Thanks

Locked