Hi all,
I've just started using this wxFreeChart (I needed the ability to create 100s of postage sized graphs). wxFreeChart is really fast an works almost perfectly.
The problem I have is that some times, the graphs are small. This causes crashes in the Plot function when w.GetScaleX() and w.GetScaleY() are less than zero.
const double dig = floor( log( 128.0 / w.GetScaleX() ) / mpLN10 );
const double step = exp( mpLN10 * dig);
const double end = w.GetPosX() + (double)extend / w.GetScaleX();
It took me ages to figure out where the crash was happening, the Visual Studio debugger gave no clue about what had happened.
Here is the code needed to fix this.
double fScale = w.GetScaleY();
double dig = 0.0;
if (fScale > 0.0)
dig = floor(log(128.0 / fScale) / mpLN10);
const double step = exp(mpLN10 * dig);
double end = 0.0;
if (fScale > 0.0)
end = w.GetPosY() + (double)extend / fScale;
double fScale = w.GetScaleX();
double dig = 0.0;
if (fScale > 0.0)
dig = floor(log(128.0 / fScale) / mpLN10);
const double step = exp( mpLN10 * dig);
double end = 0.0;
if (fScale > 0.0)
end = w.GetPosX() + (double)extend / fScale;
There are a couple of other places as well where there is no check for division by zero (eg, "double changeUnitsX = change / m_scaleX;"). I'm more than happy to make these changes and commit them if I'm allowed to do so.
All the best,
Tony.