Setting Base for bar chart in version 0.9.16

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
shamesh_joshi
Posts: 7
Joined: Mon Jun 18, 2007 8:15 am
Location: Kathmandu
Contact:

Setting Base for bar chart in version 0.9.16

Post by shamesh_joshi » Mon Jun 18, 2007 8:20 am

Hello all,
I am curently using jfreechart-0.9.16.jar. I have to set base for the bar chart, which i couldn't find how to do. so please anybody suggest me.. I can't upgrade to new version as I have to mend the chart and the chart was already using older version. :(
Regards,
Shamesh

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Mon Jun 18, 2007 9:58 am

You should get the source for the latest version of BarRenderer.java, and compare it to the BarRenderer.java file in 0.9.16. I don't recall how much has changed, but it should at least give you an indication of how you might be able to backport this feature.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

shamesh_joshi
Posts: 7
Joined: Mon Jun 18, 2007 8:15 am
Location: Kathmandu
Contact:

Post by shamesh_joshi » Mon Jun 18, 2007 10:55 am

Thank-x for the concern, can you please tell me where I can find the source file of both versions???

shamesh_joshi
Posts: 7
Joined: Mon Jun 18, 2007 8:15 am
Location: Kathmandu
Contact:

Post by shamesh_joshi » Mon Jun 18, 2007 12:02 pm

Thank you for the support. the problem is solved. It was easier than I thought.

Just extends BarRenderer add function calculateBarL0L1 to overwrite setting base.

protected double[] calculateBarL0L1(double value) {

double lclip = getLowerClip();
double uclip = getUpperClip();
double bb = this.base;
if (uclip <= 0.0) { // cases 1, 2, 3 and 4
if (value >= uclip) {
return null; // bar is not visible
}
bb = uclip;
if (value <= lclip) {
value = lclip;
}
}
else if (lclip <= 0.0) { // cases 5, 6, 7 and 8
if (value >= uclip) {
value = uclip;
}
else {
if (value <= lclip) {
value = lclip;
}
}
}
else { // cases 9, 10, 11 and 12
if (value <= lclip) {
return null; // bar is not visible
}
bb = lclip;
if (value >= uclip) {
value = uclip;
}
}
return new double[] {bb, value};
}



regards,
Shamesh

Locked