*** ../tmp/Barchart.c	Tue Mar 19 03:44:48 1991
--- Barchart.c	Fri Apr  5 12:32:37 1991
***************
*** 279,289 ****
       */
  
    if (NEW.numPoints > 0) 
!     NEW.xIncrement = ((NEW.xMax - NEW.xMin) + 1) / NEW.numPoints;
  
!   for (i=0, tempx=NEW.xMin; i < NEW.numPoints;
         i++, tempx += NEW.xIncrement)
!     NEW.xpts[i] = tempx - NEW.halfdensity;
  
    NEW.ypts = (double *) XtMalloc(sizeof(double) * NEW.numPoints);
    
--- 279,290 ----
       */
  
    if (NEW.numPoints > 0) 
!     NEW.xIncrement = ((NEW.xMax - NEW.xMin)) / (NEW.numPoints - 1);
  
!   for (i=0, tempx=NEW.xMin - NEW.halfdensity * NEW.xIncrement; 
!        i < NEW.numPoints;
         i++, tempx += NEW.xIncrement)
!     NEW.xpts[i] = tempx;
  
    NEW.ypts = (double *) XtMalloc(sizeof(double) * NEW.numPoints);
    
***************
*** 311,316 ****
--- 312,329 ----
    XtSetArg(a, XtNautoScale, &autoS);
    XtGetValues(XtParent((Widget) new), &a, 1);
  
+   if (Changed(density)) {
+     if (NEW.density < 0.0) {
+       AtWarning(new, "AtBarchart: density can not be less than zero.");
+       NEW.density = 0.0;
+     }
+     if (NEW.density > 1.0) {
+       AtWarning(new, "AtBarchart: density can not be greater than one.");
+       NEW.density = 1.0;
+     }
+     NEW.halfdensity = NEW.density / 2;
+   }
+ 
    if (Changed(numPoints)) {
      XtFree(NEW.xpts);
      XtFree(NEW.ypts);
***************
*** 322,372 ****
      NEW.ypts = (double *)XtMalloc(sizeof(double) * NEW.numPoints);
  
      if (NEW.numPoints > 0) 
!       NEW.xIncrement = ((NEW.xMax - NEW.xMin) + 1) / NEW.numPoints;
      else
        AtWarning(new, "AtBarchart: numPoints must be greater than zero");
-     for (i=0, tempx=NEW.xMin; i < NEW.numPoints;
-          i++, tempx += NEW.xIncrement)
-       NEW.xpts[i] = tempx - NEW.halfdensity;
  
      bcopy((char *)NEW.yPoints, (char *)NEW.ypts,
            sizeof(double) * NEW.numPoints);
- 
-     NEW.valid = False;
-     SetBoundingBox(new);
-     new->plot.redisplay = True; /* refresh all plots. */
    }
-   
-   if (Changed(density)) {
-     if (NEW.density < 0.0) {
-       AtWarning(new, "AtBarchart: density can not be less than zero.");
-       NEW.density = 0.0;
-     }
-     if (NEW.density > 1.0) {
-       AtWarning(new, "AtBarchart: density can not be greater than one.");
-       NEW.density = 1.0;
-     }
-     NEW.halfdensity = NEW.density / 2;
  
!     for (i=0, tempx=NEW.xMin; i < NEW.numPoints;
           i++, tempx += NEW.xIncrement)
!       NEW.xpts[i] = tempx - NEW.halfdensity;
!     
      NEW.valid = False;
      SetBoundingBox(new);
-     new->plot.redisplay = True; /* refresh all plots */
-   }
- 
-   if (Changed(xMin) || Changed(xMax)) {
-     if (NEW.numPoints > 0) 
-       NEW.xIncrement = ((NEW.xMax - NEW.xMin) + 1) / NEW.numPoints;
-     else
-       AtWarning(new, "AtBarchart: numPoints must be greater than zero\n");
-     for (i=0, tempx=NEW.xMin; i < NEW.numPoints;
- 	 i++, tempx += NEW.xIncrement)
-       NEW.xpts[i] = tempx-NEW.halfdensity;
-     NEW.valid = False;
-     SetBoundingBox(new);
      new->plot.redisplay = True; /* refresh all plots. NOTE, we may
  				   want to change this later to 
  				   refresh only this plot if no autoS.
--- 335,358 ----
      NEW.ypts = (double *)XtMalloc(sizeof(double) * NEW.numPoints);
  
      if (NEW.numPoints > 0) 
!       NEW.xIncrement = ((NEW.xMax - NEW.xMin) + 1) / (NEW.numPoints - 1);
      else
        AtWarning(new, "AtBarchart: numPoints must be greater than zero");
  
      bcopy((char *)NEW.yPoints, (char *)NEW.ypts,
            sizeof(double) * NEW.numPoints);
    }
  
!   if (Changed(numPoints) || Changed(density) ||	Changed(xMin) ||
!       Changed(xMax)) {
!     if (NEW.numPoints > 0) 
!       NEW.xIncrement = (NEW.xMax - NEW.xMin) / (NEW.numPoints - 1);
!     for (i=0, tempx=NEW.xMin - NEW.halfdensity * NEW.xIncrement; 
!          i < NEW.numPoints;
           i++, tempx += NEW.xIncrement)
!       NEW.xpts[i] = tempx;
      NEW.valid = False;
      SetBoundingBox(new);
      new->plot.redisplay = True; /* refresh all plots. NOTE, we may
  				   want to change this later to 
  				   refresh only this plot if no autoS.
***************
*** 443,449 ****
      }
      else {
          xmin = W.xpts[0];
! 	xmax = W.xpts[W.numPoints - 1] + W.density;
  
          ymin = ymax = W.ypts[0];
          for(i=1; i < W.numPoints; i++) {
--- 429,435 ----
      }
      else {
          xmin = W.xpts[0];
! 	xmax = W.xpts[W.numPoints - 1] + W.density * W.xIncrement;
  
          ymin = ymax = W.ypts[0];
          for(i=1; i < W.numPoints; i++) {
***************
*** 540,546 ****
      XSetRegion(dpy, BCW.fillGc, region);
    }
  
!   barwidth = (BCW.pixpts[1].x - BCW.pixpts[0].x) * BCW.density + 1;
  
    for (i=0; i<BCW.numPoints; i++) {
      XFillRectangle(dpy, win, BCW.fillGc, BCW.pixpts[i].x, BCW.pixpts[i].y,
--- 526,532 ----
      XSetRegion(dpy, BCW.fillGc, region);
    }
  
!   barwidth = (BCW.pixpts[1].x - BCW.pixpts[0].x) * BCW.density;
  
    for (i=0; i<BCW.numPoints; i++) {
      XFillRectangle(dpy, win, BCW.fillGc, BCW.pixpts[i].x, BCW.pixpts[i].y,
***************
*** 576,582 ****
      xpts[i] = AtScaleUserToPixel(xs, p->barchart.xpts[i])/100.0;
      ypts[i] = AtScaleUserToPixel(ys, p->barchart.ypts[i])/100.0;
    }
!   barwidth = (xpts[1] - xpts[0]) * BCW.density + 1;
  
    if (BCW.shading)
      pattern = 1.0 - ((p->barchart.pattern + 1.0) / 
--- 562,568 ----
      xpts[i] = AtScaleUserToPixel(xs, p->barchart.xpts[i])/100.0;
      ypts[i] = AtScaleUserToPixel(ys, p->barchart.ypts[i])/100.0;
    }
!   barwidth = (xpts[1] - xpts[0]) * BCW.density;
  
    if (BCW.shading)
      pattern = 1.0 - ((p->barchart.pattern + 1.0) / 
***************
*** 668,674 ****
    clipy = BCW.fillGc->values.clip_y_origin;
    clip_mask = BCW.fillGc->values.clip_mask;
  
!   barwidth = (BCW.pixpts[1].x - BCW.pixpts[0].x) * BCW.density + 1;
    
    XSetClipRectangles(dpy, BCW.fillGc, 0, 0, cliprect, 1, Unsorted);
    for (i = 0; i < BCW.numPoints; i++)
--- 654,660 ----
    clipy = BCW.fillGc->values.clip_y_origin;
    clip_mask = BCW.fillGc->values.clip_mask;
  
!   barwidth = (BCW.pixpts[1].x - BCW.pixpts[0].x) * BCW.density;
    
    XSetClipRectangles(dpy, BCW.fillGc, 0, 0, cliprect, 1, Unsorted);
    for (i = 0; i < BCW.numPoints; i++)
***************
*** 696,702 ****
    clipy = BCW.fillGc->values.clip_y_origin;
    clip_mask = BCW.fillGc->values.clip_mask;
  
!   barwidth = (BCW.pixpts[1].x - BCW.pixpts[0].x) * BCW.density + 1;
    XSetRegion (dpy, BCW.fillGc, region);
  
    for (i=0; i<BCW.numPoints; i++) 
--- 682,688 ----
    clipy = BCW.fillGc->values.clip_y_origin;
    clip_mask = BCW.fillGc->values.clip_mask;
  
!   barwidth = (BCW.pixpts[1].x - BCW.pixpts[0].x) * BCW.density;
    XSetRegion (dpy, BCW.fillGc, region);
  
    for (i=0; i<BCW.numPoints; i++) 
***************
*** 720,726 ****
    if (BCW.valid == False) Recompute(plot, xscale, yscale);
  
    rlist = (XRectangle *) XtMalloc(BCW.numPoints * sizeof(XRectangle));
!   barwidth = (BCW.pixpts[1].x - BCW.pixpts[0].x) * BCW.density + 1;
  
    for (i = 0; i < BCW.numPoints; i++)  {
      if (BCW.pixpts[i].y < BCW.oldpixpts[i].y) { /* bar growing */
--- 706,712 ----
    if (BCW.valid == False) Recompute(plot, xscale, yscale);
  
    rlist = (XRectangle *) XtMalloc(BCW.numPoints * sizeof(XRectangle));
!   barwidth = (BCW.pixpts[1].x - BCW.pixpts[0].x) * BCW.density;
  
    for (i = 0; i < BCW.numPoints; i++)  {
      if (BCW.pixpts[i].y < BCW.oldpixpts[i].y) { /* bar growing */
