Error when I custimizing my data

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Pedro Garcia Haro

Error when I custimizing my data

Post by Pedro Garcia Haro » Thu May 24, 2001 6:16 pm

Hi I'm tried to put my own data form a database in the graphs but send me this error.

Here is the code.

public XYDataSource createXYDataSource() {
Config configura = new Config();
prepareSQL sqlDatos= new prepareSQL(configura);
//here is the query
sqlDatos.setSQL("Select fecha, valor from r_diario where cve_concepto=1 ORDER BY fecha");
sqlDatos.doQuery();

Object[][][] data = new Object[1][sqlDatos.getRowCount()][2];
for (int i=0; i<sqlDatos.getRowCount(); i++) {
Vector elemento=sqlDatos.directRecord(i);
java.util.Date fecha=(java.util.Date)elemento.elementAt(0);
data[0][0]= createDate((fecha.getYear())+1900, fecha.getMonth(), fecha.getDay());
data[0][1]=new Double(Double.parseDouble(elemento.elementAt(1).toString()));
}



Object[][][] datos = new Object[][][] { {
{ createDate(2000, Calendar.JANUARY,4), new Double(1.6581) },
{ createDate(2000, Calendar.JANUARY,5), new Double(1.6566) },
{ createDate(2000, Calendar.JANUARY,6), new Double(1.6547) },
{ createDate(2000, Calendar.JANUARY,7), new Double(1.6495) }}};

The query only retrieve few data, less than 10.
When I have use few values send me this error.


Exception in thread "main" java.lang.IllegalArgumentException: period can't be longer than dataset in getMovingAvg
at com.jrefinery.chart.data.Statistics.getMovingAvg(Unknown Source) at com.jrefinery.chart.data.MovingAveragePlotFitAlgorithm.setXYDataSourc
e(Unknown Source)
at com.jrefinery.chart.data.PlotFit.getResults(Unknown Source)
at com.jrefinery.chart.data.PlotFit.getFit(Unknown Source)
at JFreeChartDemo.<init>(JFreeChartDemo.java:167)
at JFreeChartDemo.main(JFreeChartDemo.java:410)


What I missing?
There is a parameter that I must setup to manage few values?

Thanks...

David Gilbert

RE: Error when I custimizing my data

Post by David Gilbert » Wed May 30, 2001 12:43 am

Hi Pedro,

In the demo program the moving average algorithm is set to use the last 30 data points - if you have less than this, then you need to change the setting.

Regards,

DG.

Pedro Garcia Haro

RE: Error when I custimizing my data

Post by Pedro Garcia Haro » Tue Jun 12, 2001 3:58 pm

Thanks David I change the parameter and I can use this classes to my project..

Locked