This was PR #2461 which is not mergeable because of my bad rebase.
This is an attempt to allow the php code to size the graphs according the available width and height.
It uses an ajax call to populate the width and height of the browser.
To determine the size of each graph I divide the width by the number of graph to be drawn minus an arbitrary number of pixel to account for both side margins.
I have also decided to make graphs take the whole row if there is less than 800px available.
This is related to issue #2410.
Without modification :
With modification :
Store browser height and width in session using ajax call
Modify html/includes/print-graphrow.inc.php to make use of the new Session variable
Divide the width by the number of graphs in a row reduced by an arbit…
…rary value to allow margins
Only display one graph per line if width is < 800px
Update the session variables for browser width and height when browse…
…r is resized
Correct code to match code standards
Only update resolution if session variables don't exist
Tune print-graphrow.inc.php to avoid last graph going to a new line in certain cases
Make graph page use session variable to compute graph size
Add media query to cahnge the size of the thumbnails
This prevent the scrollbar on graph.inc.php
Tweaked the graphs sizing to fit better on the screen
Use media query to reduce font and img size when width is < 960px
Avoid having horizontal scrollbars.
Add more padding to accomodate row of graphs that have large y-axis text
Slightly reduced the height of rows of graphs
Round the width and height to prevent weird behavior
Remove debug echo
Only remove the height tag from the lazy loaded images
Rework the padding and ratio to better fit the lazy loading
Add reload on resize event to regenerate the graphs correctly
Calculate the height as width/2.15 to respect the old aspect ratio
Only display two graphs per line for resolution with width between 700x and 1024px
Fix infinite reload loop due to bad cherry pick
Fix code to respect coding standard
Auto-Deploy finished, Test PR at http://2510.ci.librenms.org or https://2510.ci.librenms.org
Tested, no issues here 👍
👍 from me too - larger graphs are nearly always a win, IMO.
BLOCKER: on a smartphone with softkeyboard the page reloads infinitive times as the keyboards shows on input forms (login) and causes a window resize event which then reloads the website.
Oh, I didn't think about this.
I had the feeling that the reload would trigger weird things.
I'll look into this.
@Alucardfh can't you use $('.selector').innerWidth() or so?
Yeah that's should do.
The thing is, I wanted to avoid resizing graphs on the client side because that might involve too much processing on low end device and it duplicates quite a lot of the code logic that handles how to determine the size of graphs.
Still I'll try to hack something that does it to see how it goes.
just alter the width attribute of the image and as soon as 5m the page reloads anyways - that should be fine enough
It would only works for small resize. If you make a big changes the graphs might become really hard to read.
But if we count on the 5min reload to fix it anyway, that could still do it.
I'll push an example when I get 5min.
Alternatively, can you measure the difference between the width and only reload if it's larger than say 200 px? That should be fine then as softkeyboards only alter height and not width and anything smaller than 200px could be streched/shrunk with the width attribute - or am I mistaken? (perhaps we can scrap the altering at all and only reload if the width changes?)
Replace the reload on browser resize by a graph width resize
I am actually quite surprised by the result of just changing the width.
It is not that awful even when doing large resize.
There is a few issues I have noticed : I need to add a container wrapper in the graphs images instead of directly selecting the class as the generate_lazy_tag is used at places were the resize is not working well (ex : device overview).
@Alucardfh :) shout when I should give it another test
👍 for all the work
Only resize graphs if browser resize width is less than 200px, refres…
…h the page otherwise
I made the change so graphs are resized if the browser width change for less than 200px and the page is refresh if the change is bigger.
This should prevent the issue of infinite reload on smartphone when the softkeyboard is displayed.
This also avoid reloading the page for small changes that can be accommodated on the client side.
Could you give me feedback on this ?
I couldn't reproduced the issue on my phone, but I would be happy to hear it from others.
👍 works like a charm. I'll be happy to merge it if @librenms/reviewers is happy too :)
👍 from me so merging.