Hello, everyone. Recently, when I used THttpServer to show a Canvas, I met a problem.
Referring to this example, I want to show a Canvas on the webpage. It works very well.
But when I want to show more histograms, it looks too small to see clearly. I hope that the scroll bar will be added to the canvas when I want to show more histograms on the webpage. How should I do? Does anyone have ideas?
My code:
THttpServer* serv = new THttpServer("http:8080");
TCanvas *C = new TCanvas("C","canvas");
C->Divide(8,32);
C->SetCanvasSize(1500, 1500);
C->SetWindowSize(800, 800);
C->SetFillStyle(4000);
serv->Register("/", C);
TH1F *h;
h = new TH1F("histo","",100,-5.0,5.0);
h->FillRandom("gaus",10000);
h->GetXaxis()->SetTitle("x axis");
h->GetYaxis()->SetTitle("y axis");
for(int i=0; i<256; i++)
{
C->cd(i+1);
h->Draw();
}
You are setting a canvas size of 1500 x 1500 pixels, and then dividing it into 8x32 pads. So each pad (for each histogram) only gets ~188x46 pixels. You would have to make the canvas much bigger to get bigger histograms. In any case, I don’t think it’s a good idea to have so many in one canvas, but I suppose it’s a matter of preference
Size of canvas is ignored when displayed in the web browser by JSROOT - it always scaled to available space. You should try to create several canvas with less numbers of histograms per canvas
If you have too many histograms, you can not display them at once in reasonable way.
Therefore I proposed to create several canvas for them.
Each canvas can be displayed separately using all available space in web browser.
If you still want to display all histograms at once - you need to have TCanvas with many sub-pads.
But then you should se picture like that:
You mean that if I want to display all histograms at once, I cannot display them in normal size.
If I want to display them in normal size, I have to display them on different web pages.