Eddy,
The DrawPanel redraws the selected histogram only (not the pad).
After having moved the slider, you must type at the command line
gr->Draw("CP");
This work should be done in TGraph::DrawPanel.
I have added an example of macro below illuistrating how to
create your own slider (very simple) and control what you want to do
in the interpreted code. This is quite powerful.
Just do
Root > .x gslider.C
Rene Brun
//=============macro gslider.C=============================
{
gROOT->Reset();
c1 = new TCanvas("c1","A Simple Graph Example",200,10,700,500);
c1->SetFillColor(42);
c1->SetGridx();
c1->SetGridy();
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(12);
c1->SetTopMargin(0.12);
Int_t n = 20;
Float_t x[n], y[n];
for (Int_t i=0;i<n;i++) {
x[i] = i*0.1;
y[i] = 10*sin(x[i]+0.2);
printf(" i %i %f %f \n",i,x[i],y[i]);
}
Float_t xmin = 0;
Float_t xmax = 2;
Float_t ymax = 11;
TH1F *hist = new TH1F("hist","a simple graph",100,xmin,xmax);
hist->SetMaximum(11);
hist->Draw();
hist->SetXTitle("X title");
hist->SetYTitle("Y title");
gr = new TGraph(n,x,y);
gr->SetFillColor(19);
gr->SetLineColor(2);
gr->SetLineWidth(4);
gr->SetMarkerColor(4);
gr->SetMarkerStyle(21);
gr->SetTitle("a simple graph");
gr->Draw("CP");
//Create one slider in main canvas
c1->Update();
TSlider *xslider = new
TSlider("xslider","x",xmin,ymax,xmax,ymax+0.7);
xslider->SetMethod(".x grSliderAction.C");
}
//===========macro grSliderAction.C==============
{
Int_t nx = hist->GetXaxis()->GetNbins();
Int_t binxmin = nx*xslider->GetMinimum();
Int_t binxmax = nx*xslider->GetMaximum();
hist->GetXaxis()->SetRange(binxmin,binxmax);
c1->Modified();
c1->Update();
}