How to change the series label ina JDBCXYDataset?
How to change the series label ina JDBCXYDataset?
Hi!!
I have some querys that generates a JDBCXYDataset and draw the chars greatly.
The problem is that I Can't modified this SQL instructions to put some like
Select MAX(field1), AVG(field2) from tablename
select MAX(field1) AS `max mem`, AVG(field2) AS `Average range`
from tablename
And so on with so many querys.
In this database I can load the field name label to each query, so I can get the label name for each field, but I don't know how can I put this labelname to every series.
Some tips?
I have some querys that generates a JDBCXYDataset and draw the chars greatly.
The problem is that I Can't modified this SQL instructions to put some like
Select MAX(field1), AVG(field2) from tablename
select MAX(field1) AS `max mem`, AVG(field2) AS `Average range`
from tablename
And so on with so many querys.
In this database I can load the field name label to each query, so I can get the label name for each field, but I don't know how can I put this labelname to every series.
Some tips?
I don't quite understand your question...
Can you, or can you NOT modify the SQL?
This may do the trick - but you say that you cannot (??) modify as such.
http://www.jfree.org/phpBB2/viewtopic.php?t=11439
http://www.jfree.org/phpBB2/viewtopic.php?t=11413
They may be of help. I have found that it is better to roll your own JDBC driver as eventually you will want total control.
Can you, or can you NOT modify the SQL?
This may do the trick - but you say that you cannot (??) modify as such.
see some urls:select MAX(field1) AS `max mem`, AVG(field2) AS `Average range`
http://www.jfree.org/phpBB2/viewtopic.php?t=11439
http://www.jfree.org/phpBB2/viewtopic.php?t=11413
They may be of help. I have found that it is better to roll your own JDBC driver as eventually you will want total control.
Re: Inherit and override
Hi thanks, for your response.
First, I can NOT change the sql statement, this is generate by another software.
I load this sql to make the chart. but I wan't to change the series label.
I'll try with GetSeriesName
thanks..
First, I can NOT change the sql statement, this is generate by another software.
I load this sql to make the chart. but I wan't to change the series label.
I'll try with GetSeriesName
Some sample code?Andrew Lazarus wrote:GetSeriesName
thanks..
as simple as this
Code: Select all
final static private String[] fieldList =
new String[] {"price", "slow", "fast", "modfast", "relperf", "smoothrelperf", "stage"};
/**
* getSeriesName
*
* @param series int
* @return String
*/
public String getSeriesName(int series) {
return fieldList[series];
}
I found a solution
Ok! Andrew thanks for the hint.
The problem is that I use a XYDataset and i'm not sure where to put your suggested code, beacuse my dataset is egenerated by a Query.
I add to the source code of this class next method to solve my problem.
I don't know if this was necesary or there exists another easy way to do this.
But I think that if you need make this kind of change, maybe could be add this method or another similar to this class.
The problem is that I use a XYDataset and i'm not sure where to put your suggested code, beacuse my dataset is egenerated by a Query.
I add to the source code of this class next method to solve my problem.
Code: Select all
/**
* Set the legend item labels.
*
* @param itemLabels The new legendItemLabels value
* @return a boolean.
*/
public boolean setLegendItemLabels(String[] itemLabels) {
if (itemLabels.length == this.getLegendItemCount()) {
this.columnNames=(String[]) this.getLegendItemLabels();
return true;
} else {
return false;
}
}
I don't know if this was necesary or there exists another easy way to do this.
But I think that if you need make this kind of change, maybe could be add this method or another similar to this class.
what do you mean "generated by a query"?
If you have your own class implementing XYDataset (or extending any of its implementations) you would just put my code in the class definition as an override.
You make it sound like you have something like
That makes it harder. In that case you probably have to extend and override something in XYPlot but that's an ugly solution.
You make it sound like you have something like
Code: Select all
XYDataset ds = someStaticMathodGivesMeXYDataset();
Hi Andrew.
Maybe this was an ugly solution, but I guess that you can tell me another clean way to do this.
How Can I change the Series Name Label from a JDBCXYDataset.?
This new extended method works greatly to make this kind of change to any JDBCXYDataset that I would change.
I can't implementing your suggested code, because seems like to static XYDataset. I'm not sure how to use it in a JDBCXYDataset.
Thanks for you time.
Maybe this was an ugly solution, but I guess that you can tell me another clean way to do this.
How Can I change the Series Name Label from a JDBCXYDataset.?
This new extended method works greatly to make this kind of change to any JDBCXYDataset that I would change.
I can't implementing your suggested code, because seems like to static XYDataset. I'm not sure how to use it in a JDBCXYDataset.
Thanks for you time.