summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>1999-06-12 12:38:14 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>1999-06-12 12:38:14 +0000
commitc227a1f36947df98f7e87914adc3851c0eb5bf5a (patch)
treedd51c9648062e4fdd1a0e1f969cee616af9ad4ee
parentf7c57a37300a434e946b91034fda9731656543dd (diff)
Fixed drawing bug when min == max...
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@599 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
-rw-r--r--src/Fl_Chart.cxx16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/Fl_Chart.cxx b/src/Fl_Chart.cxx
index 578a16835..9f46d3c80 100644
--- a/src/Fl_Chart.cxx
+++ b/src/Fl_Chart.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Fl_Chart.cxx,v 1.5 1999/02/01 20:15:00 mike Exp $"
+// "$Id: Fl_Chart.cxx,v 1.5.2.1 1999/06/12 12:38:14 mike Exp $"
//
// Forms-compatible chart widget for the Fast Light Tool Kit (FLTK).
//
@@ -44,9 +44,11 @@ static void draw_barchart(int x,int y,int w,int h,
/* Draws a bar chart. x,y,w,h is the bounding box, entries the array of
numb entries and min and max the boundaries. */
{
- double incr = h/(max-min);
+ double incr;
int zeroh;
double lh = fl_height();
+ if (max == min) incr = h;
+ else incr = h/(max-min);
if ( (-min*incr) < lh) {
incr = (h - lh + min*incr)/(max-min);
zeroh = int(y+h-lh);
@@ -90,8 +92,10 @@ static void draw_horbarchart(int x,int y,int w,int h,
if (w1 > lw) lw = w1;
}
if (lw > 0.0) lw += 4.0;
- double incr = w/(max-min);
+ double incr;
int zeroh;
+ if (max == min) incr = w;
+ else incr = w/(max-min);
if ( (-min*incr) < lw) {
incr = (w - lw + min*incr)/(max-min);
zeroh = x+int(lw+.5);
@@ -127,7 +131,9 @@ static void draw_linechart(int type, int x,int y,int w,int h,
{
int i;
double lh = fl_height();
- double incr = (h-2.0*lh)/ (max-min);
+ double incr;
+ if (max == min) incr = h-2.0*lh;
+ else incr = (h-2.0*lh)/ (max-min);
int zeroh = int(y+h-lh+min * incr + .5);
double bwidth = w/double(autosize?numb:maxnumb);
/* Draw the values */
@@ -371,5 +377,5 @@ void Fl_Chart::maxsize(int m) {
}
//
-// End of "$Id: Fl_Chart.cxx,v 1.5 1999/02/01 20:15:00 mike Exp $".
+// End of "$Id: Fl_Chart.cxx,v 1.5.2.1 1999/06/12 12:38:14 mike Exp $".
//