Line chart generation hangs when all values on y-axis
are zero (infinite loop)
Nobody/Anonymous
2005-05-13
Logged In: NO
The problem seems to be with the ChartUtilities.exp method
loooping infinite and taking all CPU. The following is the stack
dump indicating the thread looping at the ChartUtilities.exp().
I need this to work so i replaced with
return (int)Math.exp(d);
seems to stop the looping but the graph is unattractive.
-lp
"HttpRequestHandler-19823722" prio=5 tid=0x18417e08
nid=0x4188 runnable [191cf00
0..191cfd8c]
at de.progra.charting.ChartUtilities.exp(Unknown Source)
at de.progra.charting.ChartUtilities.calculateTickSpacing
(Unknown Source
)
at
de.progra.charting.CoordSystemUtilities.computeYAxisLabel
Width(Unknow
n Source)
at
de.progra.charting.CoordSystemUtilities.computeLeftMargin
(Unknown Sou
rce)
at de.progra.charting.CoordSystem.setBounds
(Unknown Source)
at de.progra.charting.DefaultChart.render(Unknown
Source)
at de.progra.charting.ChartEncoder.createJPEG
(Unknown Source)
at
bcc.idiv.ait.ic.monitor.servlet.ChartServlet.processRequest
(ChartServ
let.java:96)
Nobody/Anonymous
2005-05-13
Logged In: NO
Oops i forget to read what the actal exp() method does. it is
to base 10 not 'e'. Hence the math.exp() is incorrect.
My fix is to check for zero.
public static int exp(double d) {
int exp = 0;
boolean positive = (d <= -1 || d >= 1 );
if( d!=0.0)
{
while((d <= -10) || (d >= 10) || ((d > -1) && (d < 1))) {
if(positive) {
d /= 10;
exp++;
} else {
d *= 10;
exp--;
}
}
}
return exp;
Nobody/Anonymous
2005-05-13
Logged In: NO
oops. can't use math.exp() as it is calc e to a power. Instead
i just check for zero in exp().
Very little testing has been done on this, but it seeems to
work.
public static int exp(double d) {
int exp = 0;
boolean positive = (d <= -1 || d >= 1 );
if( d!=0.0)
{
while((d <= -10) || (d >= 10) || ((d > -1) && (d < 1))) {
if(positive) {
d /= 10;
exp++;
} else {
d *= 10;
exp--;
}
}
}
return exp;
Nobody/Anonymous
2007-05-23
Logged In: NO
the problem is in the Class ChartUtilities on line 200 if d==0
public static int exp(double d) {
int exp = 0;
boolean positive = (d <= -1 || d >= 1 );
while((d <= -10) || (d >= 10) || ((d > -1) && (d < 1))) {
if(positive) {
d /= 10;
exp++;
} else {
d *= 10;
exp--;
}
}