hi,
I am facing the problem to getting value withjfreetreee with date in mm-yyyy with x axis and amt as y axis.
because i am using add (double,double )method whicgh doent let me put value like march,2003 june 2004 etc and getting value form data base>>>>..
how i can get the required result?????
the sample code is here >>>>>>>>>>>
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();
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();
// series.add( str, new Double((String) entry.getValue()).doubleValue());
series.add( new Double((String) entry.getKey()).doubleValue(), new Double((String) entry.getValue()).doubleValue());
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return ChartFactory.createXYLineChart(
"Time Series Chart",
"Time in Year",
"Amount",
dataset,
PlotOrientation.VERTICAL,
true,
true,
false);
}
plz help me out.
jfreetreee with date in mm-yyyy with x axis
-
- Posts: 18
- Joined: Thu May 11, 2006 11:22 pm
Its urgent
thanks for reply,
can u tell me how i can use it becoz the code i am using is i have already posted and after searching a lot of i got nothing its urgent.
can u tell me how i can use it becoz the code i am using is i have already posted and after searching a lot of i got nothing its urgent.
-
- Posts: 18
- Joined: Thu May 11, 2006 11:22 pm
Well, let's see. I don't know anything about the actual format of the data you're getting back, but from your example you'd want something ROUGHLY like this. You'll probably have to fiddle with it a bit to get it working in the context of your project.
Code: Select all
TimeSeries series = new TimeSeries();
SimpleDateFormat dateFromText = new SimpleDateFormat("MMMM yyyy");
Set entries = mapMaxAvgAmount.entrySet();
Iterator iterator2 = entries.iterator();
while (iterator2.hasNext()) {
Map.Entry entry = (Map.Entry)iterator2.next();
Date dataDate = dateFromText((String) entry.getKey(),new ParsePosition(0));
series.add(new Month(dataDate),(Double) entry.getValue());
}