Range axis problem, data are not visible

A free public discussion forum for the JFreeChart class library.

Range axis problem, data are not visible

Postby ponto » Mon Mar 19, 2012 9:15 am

Hello, I have a problem with range axis for time series chart.
I have two or more TimeSeriesCollection datasets in a chart. Every Dataset contains one TimeSeries. If one TimeSeries is empty(without data), data of other TimeSeries are not visible, because of bad range on range axis. Chart has auto range set on true.
Can anyone help with this?
Regards
ponto
 
Posts: 5
Joined: Wed Feb 01, 2012 2:23 pm

Re: Range axis problem, data are not visible

Postby matinh » Mon Mar 19, 2012 1:16 pm

This is probably bug #3445507 which has already been fixed in SVN.
Try a recent snapshot. It should be fixed there.

hth,
- martin
matinh
 
Posts: 467
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: Range axis problem, data are not visible

Postby ponto » Mon Mar 19, 2012 3:04 pm

Hi,

I tried last snapshot from 11. March 2012, but I got the same behaviour. Here is my example code:

Code: Select all
import java.awt.BorderLayout;
import java.util.Calendar;
import java.util.Random;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.time.Millisecond;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;

public final class TestJFreechart extends javax.swing.JDialog {

    private final ChartPanel chartPanel;
    private final JFreeChart chart;
    // time series
    private final TimeSeries timeSeries1;
    private final TimeSeries timeSeries2;

    public TestJFreechart(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        setLayout(new BorderLayout());
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setMinimumSize(new java.awt.Dimension(600, 300));

        // create chart
        chart = ChartFactory.createTimeSeriesChart(
                "title", // title
                "date", // x-axis label
                "unit", // y-axis label
                null, // data
                true, // create legend?
                false, // generate tooltips?
                false // generate URLs?
                );

        // set auto range on y-axis
        chart.getXYPlot().getRangeAxis().setAutoRange(true);

        // create chart panel
        chartPanel = new ChartPanel(chart);
        chartPanel.setRangeZoomable(false);
        chartPanel.setDomainZoomable(true);
        add(chartPanel, BorderLayout.CENTER);

        // create datasets
        timeSeries1 = new TimeSeries("Dataset 1");
        chart.getXYPlot().setDataset(0, new TimeSeriesCollection(timeSeries1));

        timeSeries2 = new TimeSeries("Dataset 2");
        chart.getXYPlot().setDataset(1, new TimeSeriesCollection(timeSeries2));

        // create and start value generator
        Generator generator = new Generator();
        generator.start();
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                TestJFreechart dialog = new TestJFreechart(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // value generator
    private final class Generator extends Thread {

        @Override
        public void run() {
            Random generator = new Random();
            while (true) {
                try {
                    //timeSeries1.add(new Millisecond(Calendar.getInstance().getTime()), generator.nextDouble());
                    timeSeries2.add(new Millisecond(Calendar.getInstance().getTime()), generator.nextDouble());
                    Thread.sleep(1000);
                } catch (InterruptedException ex) {
                }
            }
        }
    }
}


If you try uncomment this line
Code: Select all
//timeSeries1.add(new Millisecond(Calendar.getInstance().getTime()), generator.nextDouble());
in Generator class, the data are displayed good. Any idea? Regards
ponto
 
Posts: 5
Joined: Wed Feb 01, 2012 2:23 pm

Re: Range axis problem, data are not visible

Postby ponto » Mon Apr 02, 2012 9:40 am

Any solution?

Michal
ponto
 
Posts: 5
Joined: Wed Feb 01, 2012 2:23 pm

Re: Range axis problem, data are not visible

Postby matinh » Tue Apr 03, 2012 12:22 pm

Hi again!

This seems like another bug related to the one I already mentioned.
I tried replacing calls to Range.combine() with Range.combineIgnoringNaA() in XYPlot.getDataRange() and this fixed it. However, I need to have a closer look before commiting this possible fix.

Thanks for reporting and watch bug #3445507 for the progress.

hth,
- martin
matinh
 
Posts: 467
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria

Re: Range axis problem, data are not visible

Postby DarkToan » Wed Nov 13, 2013 7:54 pm

Any update on this bug? The problem persist even on the 1.0.15 version, please, if you have come to a solution tell me what to use

thank you, Isaac.
DarkToan
 
Posts: 2
Joined: Wed Nov 13, 2013 7:51 pm

Re: Range axis problem, data are not visible

Postby matinh » Thu Nov 14, 2013 9:21 am

Not from my side. But the bug-report is closed. So please try with the latest version (1.0.16 currently) and if there is still a problem, create a new bug-report and link to this forum post.
A small demo for reproducing the problem would be nice to be included in the bug report.

thx,
- martin
matinh
 
Posts: 467
Joined: Fri Aug 11, 2006 10:08 am
Location: Austria


Return to JFreeChart - General

Who is online

Users browsing this forum: Yahoo [Bot] and 15 guests