Index: trunk/SophyaPI/PI/pibargraph.cc
===================================================================
--- trunk/SophyaPI/PI/pibargraph.cc	(revision 2539)
+++ trunk/SophyaPI/PI/pibargraph.cc	(revision 2542)
@@ -33,9 +33,13 @@
 
 /* --Methode-- */
-PIBarGraph::PIBarGraph()
+PIBarGraph::PIBarGraph(bool horiz, bool fill)
     : PIDrawer()
 {
+  idMin = 0.; idMax = 1.;
   mMin = 0.; mMax = 1.;
-  aColIdx = 0;
+  //DEL  aColIdx = 0;
+  fgFill = fill;
+  fgHoriz = horiz;
+  fillFrac = 0.5;
 } 
 
@@ -46,13 +50,17 @@
 
 /* --Methode-- */
-int PIBarGraph::AddBar(double val_, PIColors col_)
+int PIBarGraph::AddBar(double id_, double val_, string const& lab_, PIColors col_)
 {
   struct _bgdata bgd;
+  bgd.id = id_;
   bgd.val = val_;
+  bgd.lab = lab_;
   bgd.col = col_;
-  if (mBars.size() == 0) { mMin = mMax = val_; }
+  if (mBars.size() == 0) { mMin = mMax = val_; idMin = idMax = id_; }
   else {
     if (val_ < mMin)  mMin = val_;
     if (val_ > mMax)  mMax = val_;
+    if (id_ < idMin)  idMin = id_;
+    if (id_ > idMax)  idMax = id_;
   }
   mBars.push_back(bgd);
@@ -63,11 +71,14 @@
 int PIBarGraph::AddBar(double val)
 {
-#define NACOL_ 8  
-  PIColors autocol[NACOL_] = { PI_Red, PI_Blue, 
-                  PI_Yellow, PI_Orange, PI_Magenta, 
-                  PI_Cyan, PI_NavyBlue, PI_Green };  
-  int rc = AddBar(val, autocol[aColIdx]);
-  aColIdx = (aColIdx+1)%NACOL_;
-  return rc;
+  string lab = "";
+  double id = mBars.size()+0.5;
+  return  AddBar(id, val, lab, PI_NotDefColor);
+}
+
+
+static inline void swap_ifhoriz(double& a, double& b) 
+{
+  double tmp = a;
+  a = b;  b = a;
 }
 
@@ -77,5 +88,6 @@
   if (mBars.size() < 1)  return;
   double xmin, xmax, ymin, ymax;
-  xmin = 0.; xmax = mBars.size()+0.5;
+  xmin = idMin-fillFrac*(idMax-idMin)/mBars.size(); 
+  xmax = idMax+fillFrac*(idMax-idMin)/mBars.size();
   if (mMin*mMax >= 0.) {
     ymin = 0.; ymax = mMax*1.1;
@@ -83,4 +95,8 @@
   else {
     ymin = mMin*1.1;  ymax = mMax*1.1;
+  }
+  if (fgHoriz) {
+    swap_ifhoriz(xmin, ymin);
+    swap_ifhoriz(xmax, ymax);
   }
   PIAxes::ReSizeMinMax(isLogScaleX(),xmin,xmax);
@@ -90,4 +106,9 @@
 }
 
+static inline void swap_ifhoriz_g(PIGrCoord& a, PIGrCoord& b) 
+{
+  PIGrCoord tmp = a;
+  a = b;  b = a;
+}
 
 /* --Methode-- */
@@ -96,9 +117,27 @@
   if (mBars.size() < 1) return;
   PIGrCoord x,y,dx,dy;
+  double larg = fillFrac*(idMax-idMin)/mBars.size();
   for(unsigned int k=0; k<mBars.size(); k++) {
-    x = k+0.5; dx = 0.5;
+    x = mBars[k].id-0.5*larg; dx = larg;
     y = 0.; dy = mBars[k].val;
-    g->SelForeground(mBars[k].col);
-    g->DrawFBox(x,y,dx,dy);
+    if (mBars[k].col != PI_NotDefColor) g->SelForeground(mBars[k].col);
+    if (fgHoriz) {
+      swap_ifhoriz_g(x, y);
+      swap_ifhoriz_g(dx, dy);
+    }  
+    if (fgFill) g->DrawFBox(x,y,dx,dy);
+    else { 
+      g->DrawBox(x,y,dx,dy);
+      if ( mBars[k].lab.length() > 0 ) {
+	x = mBars[k].id;
+	y = 0.5*mBars[k].val;
+	if (fgHoriz) 
+	  g->DrawString(y, x, mBars[k].lab.c_str(), 
+			PI_VerticalCenter|PI_HorizontalCenter|PI_TextDirectionHorizontal);
+	else 
+	  g->DrawString(x, y, mBars[k].lab.c_str(), 
+			PI_VerticalCenter|PI_HorizontalCenter|PI_TextDirectionVerticalUp);
+      }
+    }
   }
 }
Index: trunk/SophyaPI/PI/pibargraph.h
===================================================================
--- trunk/SophyaPI/PI/pibargraph.h	(revision 2539)
+++ trunk/SophyaPI/PI/pibargraph.h	(revision 2542)
@@ -1,5 +1,5 @@
 // This may look like C code, but it is really -*- C++ -*-
 // Module PI : Peida Interactive  PIBarGraph
-// Drawer Y=f(X)      E.Aubourg, R. Ansari  2004
+// BarGraph drawer pairs(X_i,Y_i) -    R. Ansari  2004
 // (C) LAL (Orsay) / IN2P3-CNRS  DAPNIA/SPP (Saclay) / CEA
 
@@ -17,8 +17,8 @@
 class PIBarGraph : public PIDrawer {
 public:
-                     PIBarGraph();
+                     PIBarGraph(bool horiz=false, bool fill=true);
   virtual            ~PIBarGraph();
 
-  int                AddBar(double val, PIColors col);
+  int                AddBar(double id, double val, string const& lab, PIColors col);
   int                AddBar(double val);
   
@@ -30,9 +30,11 @@
 
 protected:
-  struct _bgdata { double val; PIColors col; };
+  struct _bgdata { double id,val; string lab; PIColors col; };
   vector<struct _bgdata> mBars;
   double mMin, mMax;
-  int aColIdx;
-};
+  double idMin, idMax;
+  bool fgFill, fgHoriz;
+  double fillFrac;
+ };
 
 
