Multiple TimeSeries scaling axis question
-
- Posts: 11
- Joined: Wed Jun 21, 2006 10:38 am
Multiple TimeSeries scaling axis question
I have a single graph that contains several timeseries, and uses multiple axes. However, whilst the time line for each series has the same date range, the values are on completely different scales.
I'd like to force the graph to scale each axis so that they all use the range [minValue - maxValue], where maxValue is the lartgest value used by *any* of the different timeseries.
Any ideas?
Thanks,
Tony[/img]
I'd like to force the graph to scale each axis so that they all use the range [minValue - maxValue], where maxValue is the lartgest value used by *any* of the different timeseries.
Any ideas?
Thanks,
Tony[/img]
-
- Posts: 11
- Joined: Wed Jun 21, 2006 10:38 am
Here's an answer
Ok, so I'm replying to my own question, how sad!
I've found the method setRange(minValue,maxValue) on the NumberAxis class, and this works great.
Tony
I've found the method setRange(minValue,maxValue) on the NumberAxis class, and this works great.
Tony
-
- Posts: 11
- Joined: Wed Jun 21, 2006 10:38 am
I've created a class that wraps the data for the graph. This has a method to return the maximum value for the timeseries.
Then I just do the following:
Hope this helps,
Tony
Then I just do the following:
Code: Select all
public class MultipleTimeSeriesGraphCustomizer implements ChartPostProcessor {
private MyGraphClass graphData;
public void processChart(Object chart, Map params) {
XYPlot plot = (XYPlot) ((JFreeChart) chart).getPlot();
// Annulus A Pressure Axis
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.getRangeAxis().setFixedDimension(15.0);
plot.getRangeAxis().setRange(0,graphData.getMaxValue());
...
}
}
Tony
-
- Posts: 11
- Joined: Wed Jun 21, 2006 10:38 am
I've created a class that wraps the data for the graph. This has a method to return the maximum value for the timeseries.
Then I just do the following:
Hope this helps,
Tony
Then I just do the following:
Code: Select all
public class MultipleTimeSeriesGraphCustomizer implements ChartPostProcessor {
private MyGraphClass graphData;
public void processChart(Object chart, Map params) {
XYPlot plot = (XYPlot) ((JFreeChart) chart).getPlot();
// Annulus A Pressure Axis
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.getRangeAxis().setFixedDimension(15.0);
plot.getRangeAxis().setRange(0,graphData.getMaxValue());
...
}
}
Tony
-
- Posts: 11
- Joined: Wed Jun 21, 2006 10:38 am
I've created a class that wraps the data for the graph. This has a method to return the maximum value for the timeseries.
Then I just do the following:
Hope this helps,
Tony
Then I just do the following:
Code: Select all
public class MultipleTimeSeriesGraphCustomizer implements ChartPostProcessor {
private MyGraphClass graphData;
public void processChart(Object chart, Map params) {
XYPlot plot = (XYPlot) ((JFreeChart) chart).getPlot();
// Annulus A Pressure Axis
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.getRangeAxis().setFixedDimension(15.0);
plot.getRangeAxis().setRange(0,graphData.getMaxValue());
...
}
}
Tony
-
- Posts: 11
- Joined: Wed Jun 21, 2006 10:38 am
I've created a class that wraps the data for the graph. This has a method to return the maximum value for the timeseries.
Then I just do the following:
Hope this helps,
Tony
Then I just do the following:
Code: Select all
public class MultipleTimeSeriesGraphCustomizer implements ChartPostProcessor {
private MyGraphClass graphData;
public void processChart(Object chart, Map params) {
XYPlot plot = (XYPlot) ((JFreeChart) chart).getPlot();
// Annulus A Pressure Axis
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.getRangeAxis().setFixedDimension(15.0);
plot.getRangeAxis().setRange(0,graphData.getMaxValue());
...
}
}
Tony
-
- Posts: 11
- Joined: Wed Jun 21, 2006 10:38 am
I've created a class that wraps the data for the graph. This has a method to return the maximum value for the timeseries.
Then I just do the following:
Hope this helps,
Tony
Then I just do the following:
Code: Select all
public class MultipleTimeSeriesGraphCustomizer implements ChartPostProcessor {
private MyGraphClass graphData;
public void processChart(Object chart, Map params) {
XYPlot plot = (XYPlot) ((JFreeChart) chart).getPlot();
// Annulus A Pressure Axis
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.getRangeAxis().setFixedDimension(15.0);
plot.getRangeAxis().setRange(0,graphData.getMaxValue());
...
}
}
Tony
its urgent
can u tell me how u put yr x axis .
becoz in my case i want its in mm-yyyy formate but not able to get it.
i am using xyseries and dont kow how to use time series so can u help me out.
i am puting my code>>>>>>>>>>
private JFreeChart createTimeSeriesChart(String sNDC, List listPBM, String sFromMonth, String sFromYear, String sToMonth, String sToYear) {
XYSeriesCollection dataset = new XYSeriesCollection();
try {
List listMaxAvgAmount = null;
Map mapMaxAvgAmount = new HashMap();
DateAxis dateAxis = null;
XYSeries series =null;
XYDataItem xyDataItem = null;
System.out.println("in servlet>>>>>..."+sFromMonth+">>>>>>"+sFromYear);
if(listPBM.size()>0)
{
for(int i=0;i<listPBM.size();i++)
{
series = new XYSeries((String)listPBM.get(i));
dataset.addSeries(series);
String str = "";
//listMaxAvgAmount = timeSeriesBean.getMaxAvgAmountForNDC(sNDC,(String)listPBM.get(i),sFromMonth,sFromYear,sToMonth,sToYear);
mapMaxAvgAmount = (Map)timeSeriesBean.getMaxAvgAmountForNDC(sNDC,(String)listPBM.get(i),sFromMonth,sFromYear,sToMonth,sToYear);
//System.out.println("in servlet>>>>>>>>>>>listMaxAvgAmount="+listMaxAvgAmount.size()+">>>>>>>>>>>"+mapMaxAvgAmount);
if(mapMaxAvgAmount.size()>0)
{
Set entries = mapMaxAvgAmount.entrySet();
Iterator iterator2 = entries.iterator();
while (iterator2.hasNext()) {
Map.Entry entry = (Map.Entry)iterator2.next();
String sMonthYear = (String)entry.getKey();
int iLenght = sMonthYear.length();
String sMonth = sMonthYear.substring(0 ,iLenght-4 );
String sYear = sMonthYear.substring(iLenght-4 ,iLenght );
System.out.println("In SErvlet>>>>>>>>>>sMonth==="+sMonth+"sYear++++"+sYear);
series.add(10,10);
// series.add( str, new Double((String) entry.getValue()).doubleValue());
series.add( new Double(sYear).doubleValue(), new Double((String) entry.getValue()).doubleValue());
// series.add(Integer.parseInt((String)entry.getKey()),Integer.parseInt((String)entry.getValue()));
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return ChartFactory.createXYLineChart(
"Time Series Chart",
"Time in Year",
"Amount",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false);
}
becoz in my case i want its in mm-yyyy formate but not able to get it.
i am using xyseries and dont kow how to use time series so can u help me out.
i am puting my code>>>>>>>>>>
private JFreeChart createTimeSeriesChart(String sNDC, List listPBM, String sFromMonth, String sFromYear, String sToMonth, String sToYear) {
XYSeriesCollection dataset = new XYSeriesCollection();
try {
List listMaxAvgAmount = null;
Map mapMaxAvgAmount = new HashMap();
DateAxis dateAxis = null;
XYSeries series =null;
XYDataItem xyDataItem = null;
System.out.println("in servlet>>>>>..."+sFromMonth+">>>>>>"+sFromYear);
if(listPBM.size()>0)
{
for(int i=0;i<listPBM.size();i++)
{
series = new XYSeries((String)listPBM.get(i));
dataset.addSeries(series);
String str = "";
//listMaxAvgAmount = timeSeriesBean.getMaxAvgAmountForNDC(sNDC,(String)listPBM.get(i),sFromMonth,sFromYear,sToMonth,sToYear);
mapMaxAvgAmount = (Map)timeSeriesBean.getMaxAvgAmountForNDC(sNDC,(String)listPBM.get(i),sFromMonth,sFromYear,sToMonth,sToYear);
//System.out.println("in servlet>>>>>>>>>>>listMaxAvgAmount="+listMaxAvgAmount.size()+">>>>>>>>>>>"+mapMaxAvgAmount);
if(mapMaxAvgAmount.size()>0)
{
Set entries = mapMaxAvgAmount.entrySet();
Iterator iterator2 = entries.iterator();
while (iterator2.hasNext()) {
Map.Entry entry = (Map.Entry)iterator2.next();
String sMonthYear = (String)entry.getKey();
int iLenght = sMonthYear.length();
String sMonth = sMonthYear.substring(0 ,iLenght-4 );
String sYear = sMonthYear.substring(iLenght-4 ,iLenght );
System.out.println("In SErvlet>>>>>>>>>>sMonth==="+sMonth+"sYear++++"+sYear);
series.add(10,10);
// series.add( str, new Double((String) entry.getValue()).doubleValue());
series.add( new Double(sYear).doubleValue(), new Double((String) entry.getValue()).doubleValue());
// series.add(Integer.parseInt((String)entry.getKey()),Integer.parseInt((String)entry.getValue()));
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return ChartFactory.createXYLineChart(
"Time Series Chart",
"Time in Year",
"Amount",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false);
}