Create barchart from a TimePeriodValuesCollection

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
JoshRountree
Posts: 14
Joined: Thu Mar 02, 2006 9:00 pm

Create barchart from a TimePeriodValuesCollection

Post by JoshRountree » Mon May 07, 2007 3:34 pm

Hi, right now I have created an XYBarChart using a TimePeriodValuesCollection. My data is spaced out quite a bit since the time between data is large. Sometimes this results in a chart that has very small, almost indistinguishable, bars.

My thought is to do away with the time aspect of the data.

What I want is a bar chart, or histogram, where the width of the bar is based upon a time period. What I can't figure out is which class I need to use to hold my translated TimePeriodValuesCollection.

Is an XYBarDataset wrapped around an XYIntervalSeriesCollection the right place to start looking?

JoshRountree
Posts: 14
Joined: Thu Mar 02, 2006 9:00 pm

Post by JoshRountree » Fri Sep 21, 2007 4:05 am

Anyone know why a NumberAxis is returned for a dataset of type TimePeriodValuesCollection?

I figured out the previous question...

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 » Fri Sep 21, 2007 10:24 am

JoshRountree wrote:Anyone know why a NumberAxis is returned for a dataset of type TimePeriodValuesCollection?
Returned from where?
David Gilbert
JFreeChart Project Leader

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

JoshRountree
Posts: 14
Joined: Thu Mar 02, 2006 9:00 pm

Post by JoshRountree » Fri Sep 21, 2007 8:02 pm

If I create a TimePeriodValuesCollection and use it in the ChartFactory.createXYBarChart method to create a chart, I recieve a NumberAxis object returned from the getDomainAxis() method of the Plot class recieved from the created Chart object.

Am I doing something wrong. I have the JFreeChart manual and demo program. In your manual you mention being able to do this and have source to do this, but it isn't in the demo.

Also the source that does this creates an XYItemRenderer, DateAxis, and XYPlot manually, then creates the chart without the chart factory methods.

This way works and was my work around.

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Post by skunk » Fri Sep 21, 2007 8:17 pm

What value are you passing for the third argument?

Code: Select all

1260         * @param dateAxis  make the domain axis display dates?

1271        public static JFreeChart createXYBarChart(String title,
1272                                                  String xAxisLabel,
1273                                                  boolean dateAxis,
1274                                                  String yAxisLabel,
1275                                                  IntervalXYDataset dataset,
1276                                                  PlotOrientation orientation,
1277                                                  boolean legend,
1278                                                  boolean tooltips,
1279                                                  boolean urls) {

JoshRountree
Posts: 14
Joined: Thu Mar 02, 2006 9:00 pm

Post by JoshRountree » Fri Sep 21, 2007 8:38 pm

skunk wrote:What value are you passing for the third argument?

Code: Select all

1260         * @param dateAxis  make the domain axis display dates?

1271        public static JFreeChart createXYBarChart(String title,
1272                                                  String xAxisLabel,
1273                                                  boolean dateAxis,
1274                                                  String yAxisLabel,
1275                                                  IntervalXYDataset dataset,
1276                                                  PlotOrientation orientation,
1277                                                  boolean legend,
1278                                                  boolean tooltips,
1279                                                  boolean urls) {

Wow, I'm an idiot...

Thanks for the help!

Locked