Hi,
How could I feed create*BarChart() (or any other chart that requires CategoryDataset or PieDataset) with of JDBCChartApapter?
Thanks a lot in advance
Andy
JDBCChartAdapter and BarChart
Re: JDBCChartAdapter and BarChart
The modification that works for me:
1. Make JDBCChartAdapter "implements CategoryDataset"
2. Modify executeQuery to support CHAR & VARCHAR datatypes as valid column values (Category may be a character)
3. Add 3 method implementations from CategoryDataset interface:
/**
* Returns the number of categories in the dataset.
* @return The number of categories in the dataset.
*/
public int getCategoryCount() {
return rows.size();
}
/**
* Returns a list of the categories in the dataset.
* @return A list of the categories in the dataset.
*/
public List getCategories() {
List l = new ArrayList();
for (int i = 0; i < rows.size(); i++) {
l.add( ((Vector) rows.elementAt(i)).elementAt(0) );
}
return l;
}
/**
* Returns the value for a series and category.
* @param series The series (zero-based index).
* @param category The category.
*/
public Number getValue(int series, Object category) {
for (int i = 0; i < rows.size(); i++) {
Object cat = ((Vector) rows.elementAt(i)).elementAt(0);
if (cat == category) {
return getYValue( series, i );
}
}
return null;
}
Known issues:
- CHAR & VARCHAR datatypes are allowed for all columns (should be for first only)
It would be great to see same implementation in next JDBCChartAdapter release.
Thanks
Andy
1. Make JDBCChartAdapter "implements CategoryDataset"
2. Modify executeQuery to support CHAR & VARCHAR datatypes as valid column values (Category may be a character)
3. Add 3 method implementations from CategoryDataset interface:
/**
* Returns the number of categories in the dataset.
* @return The number of categories in the dataset.
*/
public int getCategoryCount() {
return rows.size();
}
/**
* Returns a list of the categories in the dataset.
* @return A list of the categories in the dataset.
*/
public List getCategories() {
List l = new ArrayList();
for (int i = 0; i < rows.size(); i++) {
l.add( ((Vector) rows.elementAt(i)).elementAt(0) );
}
return l;
}
/**
* Returns the value for a series and category.
* @param series The series (zero-based index).
* @param category The category.
*/
public Number getValue(int series, Object category) {
for (int i = 0; i < rows.size(); i++) {
Object cat = ((Vector) rows.elementAt(i)).elementAt(0);
if (cat == category) {
return getYValue( series, i );
}
}
return null;
}
Known issues:
- CHAR & VARCHAR datatypes are allowed for all columns (should be for first only)
It would be great to see same implementation in next JDBCChartAdapter release.
Thanks
Andy
Re: JDBCChartAdapter and BarChart
Andy
Thanks for the code. I will have a look shortly.
Bryan
Thanks for the code. I will have a look shortly.
Bryan
Re: JDBCChartAdapter and BarChart
Andy
I have had a look, and will use the code. Though I have decided that to make the jdbc code better fit in with exist data sources, there will be two classes and that these will move to com.jrefinery.data with class names to match existing Default names ie:
JdbcXYDataset
JdbcCategoryDataset
(I suspect that Meter, Pie etc will follow)
I will send to david, in next week for inclusion if he agrees. I need a bit time to repackage the WAR file and create examples.
NB. There is a developer list on sourceforge as well.
I have had a look, and will use the code. Though I have decided that to make the jdbc code better fit in with exist data sources, there will be two classes and that these will move to com.jrefinery.data with class names to match existing Default names ie:
JdbcXYDataset
JdbcCategoryDataset
(I suspect that Meter, Pie etc will follow)
I will send to david, in next week for inclusion if he agrees. I need a bit time to repackage the WAR file and create examples.
NB. There is a developer list on sourceforge as well.
Re: JDBCChartAdapter and BarChart
This sounds good, I'll look forward to receiving the code.
Regards,
DG.
Regards,
DG.
Re: JDBCChartAdapter and BarChart
Bryan, David
Sounds great. I am keen on using new code (including JDBCPie
)...
Thanks
Andy
Sounds great. I am keen on using new code (including JDBCPie

Thanks
Andy