XYBarChart with TimeSeriesCollection

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
MP3HiFi
Posts: 12
Joined: Fri Apr 11, 2008 8:02 am

XYBarChart with TimeSeriesCollection

Post by MP3HiFi » Mon Oct 20, 2008 11:08 am

Hello,

I have some questions concerning the XYBarChart with TimeSeries.

I added monthly values with the following code:

Code: Select all

dataset.add(new org.jfree.data.time.Month(date),value, "Quantile" );
Additionaly I add a marker with the following code:

Code: Select all

ValueMarker mark = new ValueMarker(date, Color.DARK_GRAY, new BasicStroke(1));
plot.addDomainMarker(mark, Layer.BACKGROUND);
The date of the marker is the same as the date from the dataset. Why is the marker painted on the right side of the bar. I would like to paint it in the center or on the left side of the bar.
Anonther question is, how can I adjust the width of the bar. Especially when using Day instead of month the width of the bar is 1px. I have searched a lot in the forum, but there is no answer which helped me.

I am using version 1.0.9.

Perhaps anybody has a solution for that. Thanks for your help.

Bye
Martin

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Post by paradoxoff » Mon Oct 20, 2008 5:35 pm

Hi,
though I have no experience with the TimeSeriesCollection and RegularTimePeriod classes, here is an idea:

The bar of an XYBarChart is covering a value range along the range axis. In case of a TimeSeriesCollection (which implements IntervalXYDataset and can thus be used with an XYBarRenderer) the value range is probably defined by the range of the RegularTimePeriod implementation that you use for construction the data items.

In your case you are using the Month class, and the width of each bar should be a month.

The value for your value marker is just a single value, not a range, and will be plotted as a single line at exactly the position (or in your case at the Date) that you have selected.

I assume that you are using a Date near the end of the month for constructing boh the ValueMarker and the TimeSeries data item. Try to use a Date that is located in the middle of the month.
For the reason outlined above, freely setting the width of the bar may not be possible, since you have set that to be a Month. You could try using the Week class instead if a Month is too big and a Day is too narrow.

MP3HiFi
Posts: 12
Joined: Fri Apr 11, 2008 8:02 am

Post by MP3HiFi » Mon Oct 20, 2008 6:05 pm

Hi paradoxoff,

you are right. I am using the Date of the monthend. The problem is, that I get the data from a database. To change it, I have to convert all the data when selecting. The timeseries consist of monthly data.

I will take a closer look at this tomorrow. Perhaps I have to implement my own renderer.

Bye
Martin

Locked