How to set the size for Canvas to show more histograms clearly when using THttpServer?

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->SetCanvasSize(1500, 1500);
   C->SetWindowSize(800, 800);
   serv->Register("/", C);

   TH1F *h;
   h = new TH1F("histo","",100,-5.0,5.0);
   h->GetXaxis()->SetTitle("x axis");
   h->GetYaxis()->SetTitle("y axis");
  for(int i=0; i<256; i++)

The result:

My ROOT Version: 6.24/06
My Platform: Centos7
My Compiler: 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)

Thanks in advance.

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 :slight_smile:

Thank you. But when I set the canvas size of 15000*15000 pixels, it seems no change.

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

Thank you. If I create several canvases, I have another question.
How should I show them on the same webpage?


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:


Thank you. I got it.

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.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.