PeriodAxis - bugs found - including test case

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
mosabua

PeriodAxis - bugs found - including test case

Post by mosabua » Thu Jun 23, 2005 11:28 pm

Hi!

I think I found a bug with the PeriodAxis that persist even in the rc1 version. I have tried the following code slab with 0.9.21, pre2 and rc1.

Code: Select all

import java.awt.Color;
import java.io.File;
import java.io.IOException;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.PeriodAxis;

public class PeriodAxisTest {
	
	public static void main(String[] args) {
	    
		JFreeChart chart = ChartFactory.createTimeSeriesChart(
				"Test", "Category", "Value", null, false, false, false);
        chart.getXYPlot().setDomainAxis(new PeriodAxis("Period"));
        chart.getXYPlot().getDomainAxis().setLabelPaint(Color.white); // works
        chart.getXYPlot().getDomainAxis().setTickLabelPaint(Color.white); // doesn't work
        chart.getXYPlot().getDomainAxis().setTickLabelsVisible(false); // doesn't work
		
		try
        {
			File chartFile = new File("PeriodAxisTest.png");
            ChartUtilities.saveChartAsPNG(chartFile, chart, 640, 480);
        }
        catch (IOException e)
        {
            System.out.print(e);
        }
	}
}
This chart doesn't have any data, but thats beyond the point. The PeriodAxis tick label displayed are Dec and 1969 (since Java data 0 is then...).

I would assume that the setTickLabelsVisible(false) hides the tick labels. This in fact works with other Axis but not with PeriodAxis. Similarily I would expect that the font of the tick labels turn to white upon the setTickLabelPaint(Color.white) calls.

However neither seems to do their job.

At this stage I will have to look at another method to hide the axis tick labels if there is no data for my chart available. Any recommendations?

Thanks a lot for the great jfreechart!

Manfred[/code]

mosabua

Problem still exists with latest 1.0.1 release

Post by mosabua » Fri Feb 03, 2006 6:07 pm

I just implemented the latest bug release and found that this problem still exists.

manfred

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue Feb 07, 2006 7:01 pm

Thanks for the report. I'll take a look...
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

rantfoil
Posts: 9
Joined: Tue Dec 06, 2005 9:53 pm

workaround

Post by rantfoil » Fri Jul 07, 2006 4:33 am

This is happening because PeriodAxis uses its own PeriodAxisLabelInfo array.

You can work around this by doing creating your own PeriodAxisLabelInfo array and specify the desired stroke / paint etc. using the FULL constructor for PeriodAxisLabelInfo. The constructor of HPeriodAxis uses the short form which assumes a bunch of defaults.

Locked