Results 1 to 5 of 5
  1. #1
    cowboy is offline Member
    Join Date
    Oct 2009
    Posts
    48
    Rep Power
    0

    Default Problem with DateAxis

    I ve created a chart with Jfreechart. X axis contain time values. I set in a TIMESERIES only values betwen 10:30 and 23:45 with minute interval. But JfreeChat fill all data from 23:45 to 10:30 (painting the straigth line)and it is not correct for me. It is a printscreen :

    It is a code :
    Java Code:
     Db my=new Db("com.mysql.jdbc.Driver","jdbc:mysql://localhost/mysql","root","");
            Spinner_model spiners=new Spinner_model(jSpinner1,jSpinner2);
    
            String start_date=spiners.get_start_date();
            String start_time=spiners.get_start_time();
            
            String finish_date=spiners.get_finish_date();
            String finish_time=spiners.get_finish_time();
    
    
            final TimeSeries series = my.get_dataset(start_date, finish_date);
            final XYDataset dataset = new TimeSeriesCollection(series);
    
            JFreeChart chart =ChartFactory.createTimeSeriesChart(
                "Test",
                "Day",
                "Value",
                dataset,
                false,
                false,
                false
            );
    
            chart.setBackgroundPaint(Color.white);
    
    
            final XYPlot plot = chart.getXYPlot();
           
            plot.setBackgroundPaint(Color.lightGray);
            plot.setDomainGridlinePaint(Color.white);
            plot.setRangeGridlinePaint(Color.white);
            plot.setDomainCrosshairVisible(true);
            plot.setRangeCrosshairVisible(false);
    
            final XYItemRenderer renderer = plot.getRenderer();
            if (renderer instanceof StandardXYItemRenderer) {
                final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer;
             
                rr.setShapesFilled(true);
                renderer.setSeriesStroke(0, new BasicStroke(2.0f));
                renderer.setSeriesStroke(1, new BasicStroke(2.0f));
               }
    
            final DateAxis axis = (DateAxis) plot.getDomainAxis();
            axis.isAutoRange();
            
    
            final ChartPanel chartPanel = new ChartPanel(chart);
            jScrollPane1.setViewportView(chartPanel);

  2. #2
    yanivby is offline Member
    Join Date
    Jan 2010
    Posts
    13
    Rep Power
    0

    Default

    Maybe that's too obvious but you haven't mentioned that: are you sure there's actually any data between 00:00 and 10:00? Seems like the database doesn't have points in that interval and Jfreechart just draws a line between the last point just before 00:00 and the one after 10:00.
    Or is that obvious to you and you're really asking how to eliminate this straight line in such cases?

  3. #3
    cowboy is offline Member
    Join Date
    Oct 2009
    Posts
    48
    Rep Power
    0

    Default

    You are rigth. Database have no data to this time interval. This chast-quotes from stock exchange. Trading occur from 10.30 till 23.45. In the rest time no data.How i can hide this straight line?

  4. #4
    yanivby is offline Member
    Join Date
    Jan 2010
    Posts
    13
    Rep Power
    0

    Default

    I'm not sure if that's possible.
    What you actually want to tell JFreeChat is not to draw a line in case there are no points in a delta larger than X. Or, perhaps there's a way to create multiple data sets. If there is, you could create a separate dataset for each cluster of points.
    You'll have to look at the documentation of JFreeChart, or check if there's an active forum/mailing-list for this project where you can ask.
    In the worst case you may have to find an alternative chart framework, or even modify the code of JFreeChart (I assume it's open source).
    But I hope it won't come to that...

  5. #5
    cowboy is offline Member
    Join Date
    Oct 2009
    Posts
    48
    Rep Power
    0

    Default

    Thanks to all..I suppose the most appreciate way for resolve this issue-
    1.create a YXSERIES with number values on X axis
    2.Hide X axis
    3. Draw the new axis on another paint and put it under chartPanel..

    From Russia with Love! :)

Similar Threads

  1. simple line problem / for loop problem
    By helpisontheway in forum New To Java
    Replies: 1
    Last Post: 11-17-2009, 07:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •