Hello:
Is there an easy way to say that the Y axis should display a minimum range, for example, 5 units?
Our charts only have 1 unit displayed on the Y axis and it looks funny.
I know that I can set teh range manually, but I would still like it to auto size.
Thanks,
Neil.
Minimum range for Y axis?
Re: Minimum range for Y axis?
Hi Neil,
There is a setAutoRangeMinimumSize(...) method in the NumberAxis class, which might help. If not, e-mail me a sample chart showing the problem...
Regards,
DG.
There is a setAutoRangeMinimumSize(...) method in the NumberAxis class, which might help. If not, e-mail me a sample chart showing the problem...
Regards,
DG.
Re: Minimum range for Y axis?
David:
I tried using the setAutoRangeMinimumSize(), but it did not change
the chart.
I had to solve the problem, so I set up my own scaling in my code.
I will try to put together a sample chart to illustrate the problem.
Thanks,
Neil
I tried using the setAutoRangeMinimumSize(), but it did not change
the chart.
I had to solve the problem, so I set up my own scaling in my code.
I will try to put together a sample chart to illustrate the problem.
Thanks,
Neil
Re: Minimum range for Y axis?
David:
Here is a sample chart:
http://www.jammconsulting.com/burnrated ... rtTest.jsp
Here is the code I used to generate it:
// Create a time series data set for the chart
TimeSeriesCollection dataSet = new TimeSeriesCollection();
// Create a time series for the scale weights
BasicTimeSeries series1 = new BasicTimeSeries("Series 1");
dataSet.addSeries(series1);
series1.add(new Day(new Date()),new Integer(190));
// Create the chart
JFreeChart chart = ChartFactory.createTimeSeriesChart("Test Chart","Date","Values",dataSet,true);
// Make sure the y axis has only integer tick units
TickUnits integerTicks = TickUnits.createIntegerTickUnits();
((NumberAxis)chart.getPlot().getAxis(Axis.VERTICAL)).setStandardTickUnits(integerTicks);
// Set the axis range to go between the min wieght and max weight
((NumberAxis)chart.getPlot().getAxis(Axis.VERTICAL)).setAutoRangeMinimumSize(new Integer(5));
I called auto range minimum size with 5 units, but the chart is only displaying one since there is only a single data point.
Is there a similar method such as set auto range minimum size for a date axis? I did not see one in the docs.
Thanks,
Neil.
Here is a sample chart:
http://www.jammconsulting.com/burnrated ... rtTest.jsp
Here is the code I used to generate it:
// Create a time series data set for the chart
TimeSeriesCollection dataSet = new TimeSeriesCollection();
// Create a time series for the scale weights
BasicTimeSeries series1 = new BasicTimeSeries("Series 1");
dataSet.addSeries(series1);
series1.add(new Day(new Date()),new Integer(190));
// Create the chart
JFreeChart chart = ChartFactory.createTimeSeriesChart("Test Chart","Date","Values",dataSet,true);
// Make sure the y axis has only integer tick units
TickUnits integerTicks = TickUnits.createIntegerTickUnits();
((NumberAxis)chart.getPlot().getAxis(Axis.VERTICAL)).setStandardTickUnits(integerTicks);
// Set the axis range to go between the min wieght and max weight
((NumberAxis)chart.getPlot().getAxis(Axis.VERTICAL)).setAutoRangeMinimumSize(new Integer(5));
I called auto range minimum size with 5 units, but the chart is only displaying one since there is only a single data point.
Is there a similar method such as set auto range minimum size for a date axis? I did not see one in the docs.
Thanks,
Neil.
Re: Minimum range for Y axis?
Hello:
I was playing around a little more with my graph at:
http://www.jammconsulting.com/burnrated ... rtTest.jsp
I added code to set the minimum and maximum values for the x-axis
using this code:
// Create a time series data set for the chart
TimeSeriesCollection dataSet = new TimeSeriesCollection();
// Create a time series for the scale weights
BasicTimeSeries series1 = new BasicTimeSeries("Series 1");
dataSet.addSeries(series1);
series1.add(new Day(new Date()),new Integer(190));
// Create the chart
JFreeChart chart = ChartFactory.createTimeSeriesChart("Test Chart","Date","Values",dataSet,true);
// Make sure the y axis has only integer tick units
TickUnits integerTicks = TickUnits.createIntegerTickUnits();
((NumberAxis)chart.getPlot().getAxis(Axis.VERTICAL)).setStandardTickUnits(integerTicks);
// Set the axis range to go between the min wieght and max weight
((NumberAxis)chart.getPlot().getAxis(Axis.VERTICAL)).setAutoRangeMinimumSize(new Integer(5));
// Set the x-axis range to go between yesterday and 5 days from now.
GregorianCalendar minCalendar = new GregorianCalendar();
GregorianCalendar maxCalendar = new GregorianCalendar();
minCalendar.setTime(new Date());
maxCalendar.setTime(new Date());
minCalendar.roll(Calendar.DAY_OF_MONTH,-1);
minCalendar.roll(Calendar.DAY_OF_MONTH,5);
((DateAxis)chart.getPlot().getAxis(Axis.HORIZONTAL)).setMinimumDate(minCalendar.getTime());
((DateAxis)chart.getPlot().getAxis(Axis.HORIZONTAL)).setMaximumDate(maxCalendar.getTime());
And the chart is not showing the dates that I set for the x-axis.
I am using jfreechart 0.8.1
Is this a bug?
Thanks,
Neil.
I was playing around a little more with my graph at:
http://www.jammconsulting.com/burnrated ... rtTest.jsp
I added code to set the minimum and maximum values for the x-axis
using this code:
// Create a time series data set for the chart
TimeSeriesCollection dataSet = new TimeSeriesCollection();
// Create a time series for the scale weights
BasicTimeSeries series1 = new BasicTimeSeries("Series 1");
dataSet.addSeries(series1);
series1.add(new Day(new Date()),new Integer(190));
// Create the chart
JFreeChart chart = ChartFactory.createTimeSeriesChart("Test Chart","Date","Values",dataSet,true);
// Make sure the y axis has only integer tick units
TickUnits integerTicks = TickUnits.createIntegerTickUnits();
((NumberAxis)chart.getPlot().getAxis(Axis.VERTICAL)).setStandardTickUnits(integerTicks);
// Set the axis range to go between the min wieght and max weight
((NumberAxis)chart.getPlot().getAxis(Axis.VERTICAL)).setAutoRangeMinimumSize(new Integer(5));
// Set the x-axis range to go between yesterday and 5 days from now.
GregorianCalendar minCalendar = new GregorianCalendar();
GregorianCalendar maxCalendar = new GregorianCalendar();
minCalendar.setTime(new Date());
maxCalendar.setTime(new Date());
minCalendar.roll(Calendar.DAY_OF_MONTH,-1);
minCalendar.roll(Calendar.DAY_OF_MONTH,5);
((DateAxis)chart.getPlot().getAxis(Axis.HORIZONTAL)).setMinimumDate(minCalendar.getTime());
((DateAxis)chart.getPlot().getAxis(Axis.HORIZONTAL)).setMaximumDate(maxCalendar.getTime());
And the chart is not showing the dates that I set for the x-axis.
I am using jfreechart 0.8.1
Is this a bug?
Thanks,
Neil.