Results 1 to 5 of 5
Thread: Problem with DateAxis
- 01-04-2010, 05:20 PM #1
Member
- Join Date
- Oct 2009
- Posts
- 48
- Rep Power
- 0
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);
- 01-04-2010, 09:28 PM #2
Member
- Join Date
- Jan 2010
- Posts
- 13
- Rep Power
- 0
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?
- 01-05-2010, 05:46 PM #3
Member
- Join Date
- Oct 2009
- Posts
- 48
- Rep Power
- 0
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?
- 01-07-2010, 09:56 PM #4
Member
- Join Date
- Jan 2010
- Posts
- 13
- Rep Power
- 0
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...
- 01-08-2010, 08:41 AM #5
Member
- Join Date
- Oct 2009
- Posts
- 48
- Rep Power
- 0
Similar Threads
-
simple line problem / for loop problem
By helpisontheway in forum New To JavaReplies: 1Last Post: 11-17-2009, 06:12 AM


LinkBack URL
About LinkBacks

Bookmarks