-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Network with 100% height set does not render correctly #1832
Comments
I've made a tweak to your code; Basically, you can't use %, you need to "px". Here is the new code example from your fork, look at your script.js: |
Problem is this isn't dynamic - my understanding is that to get the network autoResize to work, it needs to be in % not px - otherwise it won't think to resize (as it's still rendering at the fixed width). I assume on resize I could try to recalculate, but I need it to fill 100% of the container, rather than window size. I'm using this in bootstrap where it's inside a 9 col div (where the full 12 col set are nested inside a 9 col div). I know from prior experience that trying to render svg/canvas to fill 100% of a container is not the easiest thing though. |
Had to hardcode it in the options to 600px because of issue as described in this issue: almende/vis#1832
Currently there is a bug in vis.js which means its size is set to a hardcoded value of 150px, even though we set it to 100% in a reactive framework (bootstrap). * See almende/vis#1832 As a workaround canvas size is set manually after attaching the vue component & on window resize.
Currently there is a bug in vis.js which means its size is set to a hardcoded value of 150px, even though we set it to 100% in a reactive framework (bootstrap). * See almende/vis#1832 As a workaround canvas size is set manually after attaching the vue component & on window resize.
I'm closing this issue due to inactivity. |
I still see this happening with 4.20.1 |
http://plnkr.co/edit/2FGTOd8v2GbmwGgeYAVu?p=preview |
@pjeutr Thanks for demo, that's useful. Makes it much easier to examine the issue. |
@pjeutr the funny thing is, I can't reproduce it on my computer. The layout looks just fine to me, even if I resize the browser window (linux+ firefox/chrome). The plunker demo does display the autoscaling problem, though. Any way to force it? |
@wimrijnders Thanks for looking into this. Just to be clear this is what I see on osx ( firefox / safari / chrome ) The red border is the size of the VisJS canvas. |
Yeah, my bad. I neglected to copy the CSS from plunker. I see it now as well. Sorry to correct you, but you are using |
Sorry! Must have been because I use Graph as model name. Never heard of GraphJS before. |
OK, I can see it happening, so: Confirmed. It's actually useful that you added the other module; since they are doing something right, I might be able to peek in their code and find out how they fix it. I'll keep you up to date. |
Here is where the magic happens. I think. Will verify. For comparison, this is what |
This is essentially the problem. We need to ensure that the defaults for the |
Wow, w3c? Good find! |
Hehe, now we know where that 150 comes from. This headache will be solved soon. |
I had this issue awhile back and here is how it resolved it. By default vis.js network height is 100% which is correct. However the default height for canvas, like @wimrijnders says, is 150px. Since the canvas is inside the 'mynetwork' div (default height: auto) tag, it's can only expand as big as the canvas, which is 150px height. In order to adjust to 100% of what YOU want, you have to calculate and adjust the height of the 'mynetwork' div tag, then the canvas can fully resize to whatever you want. Here is a fork of your @pjeutr code, where i adjust the height of the div tag. You can take a look at: http://plnkr.co/edit/Kkz8SZDgv93yPRpRxckZ?p=preview Hope this helps! |
@dragonzone Great, thanks. But where is the fix exactly in the demo? I can't seem to find it. |
Aha. This is a giveaway of what's happening. Autoresize is refreshing about once per second, so you really are seeing this happening. There must be better solutions. I have a one-liner idea for this...
Meaning, that the networks are still visible on screen but it doesn't resize along? This is something that can be focused on. |
Correct, networks are still visible. But doesn't resize. Testing MS browser behaviour is great using vm's. MS provides images themselves |
OK, my initial hunch was incorrect. I've been doing some online snooping with respect to Safari compatibility, it appears to be OK from Safari 6.1 onwards. The only thing I can think of is that the canvas rendering is slower on safari, causing the redraw to go over a frame. I'm looking for a benchmark to test this. This looks hopeful, but I can't get it to run. Update: Running now. I think the page got the hint after I furiously kept on tapping F5. Would you mind running that test on Safari? To see if the canvas rendering time could be an issue. These are my scores:
|
Seems all OK. This is me:
iPhone SE
Rasberry Pi (the first) + Raspbian ( kitties like to be challenged! )
|
So I finally read the instructions on the benchmark page:
So it's not an absolute measure. The only thing that can be looked at is your results for the different browsers on the MB. I was hoping for a clear indication that Safari is slower with the rendering. It's clearly slower than chrome, but comparable to firefox, of which you said there is no flicker problem. So I'm inclined to conclude that this test is moot. For completeness:
Seeing that the i7 was +-60FPS and the RPi +-12FPS, it's safe to say that comparing values between machines is meaningless. Apologies if I have wasted your time. |
IMHO, the flickering comes from here:
setOptions(options) {
if (options !== undefined) {
let fields = ['width','height','autoResize'];
util.selectiveDeepExtend(fields,this.options, options);
}
if (this.options.autoResize === true) {
// automatically adapt to a changing size of the browser.
this._cleanUp();
this.resizeTimer = setInterval(() => { // <=== Timer resizing every second!!
let changed = this.setSize();
if (changed === true) {
this.body.emitter.emit("_requestRedraw");
}
}, 1000); // <=== End timer
this.resizeFunction = this._onResize.bind(this);
util.addEventListener(window,'resize',this.resizeFunction);
}
} This thing looks dated to me, more so since New demo. The only thing changed from previous is the reference to |
Yup, it works. Also tried it locally by removing the timer. That was the culprit. |
Yay! That means we're done with the fix. One thing to do for me: add unit tests. (Anything I missed? Just checking) |
Nope, thanks! |
Hehe. Decade is like an epoch in the javascript world. I wouldn't count on it. OK, until next time! I believe you'll get a notification here when the PR has been published. |
@pjeutr I'm rounding off the PR here. Question: Would you mind if I added the last demo you gave me to the examples? This to showcase that the dynamic sizing works. It's pretty complete and visually enticing. TIA! |
Sure, No problem. Glad I could contribute.
… On 23 Oct 2017, at 08:57, wimrijnders ***@***.***> wrote:
@pjeutr <https://github.com/pjeutr> I'm rounding off the PR here.
Question: Would you mind if I added the last demo you gave me to the examples? This to showcase that the dynamic sizing works. It's pretty complete and visually enticing.
TIA!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#1832 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAlWgBvQ2ZRd87Uik4RuhZAm8-Q3s-wmks5svDjOgaJpZM4IS6kN>.
|
Thanks for that! I will attribute you in the source code. |
Hi, is there a schedule for when this change will be released? Was this tested also with bootstrap grid layout (row + col-xx-xx) ? |
Hi Wim I just noticed the edge labels are missing, see also the plnkr demo. @glaggia-larus |
After 1,5 days of investigation, I found this thread. I manage to do a single test for me using this gist: If I remove the doctype html (html5) it fit nicely There is no example for a fullscreen mode. All examples I looked at are boxed. Also: |
Ops. Html5 makes it working, but it affects view of many other page elements, so I have to validate and fix all pages. I agreed up on a workaround where parent div using fixed position, because anyway graph view should be as big as possible and it would occupy the entire screen. Sparse buttons would be located inside the view with transparent background. |
@wimrijnders Hi, what is the current state of this issue? I can give a hand if the branch or the PR is published, thanks |
I have been struggling with sizing network canvas based on the height of the available space... and when a user resizes the browser window. After a bit of testing and playing around -- I figured this out, seems to work. If you have alternative approaches, please post a suggestion or alternative example code. I hope this helps others as a starting point for their own projects. Note: I am using jQuery to help streamline the resize functions. IMPORTANT - NON-HMTL5 DOCTYPE
THE HEAD SECTION
SAMPLE BODY CONTENT
THE SCRIPT (bottom of the HTML BODY)
|
I'm also affected ;_; |
@LilRed -- did my example NOT help you? It seems to work fine for me across all browsers. |
I'm using vis to make Grafana panel plug-ins, so I don't have control over the doctype. |
Oh - yea -- that was the only work around I found.... :( |
Another workaround: network.once('afterDrawing', () => {
container.style.height = '100vh'
}) |
I'm trying to use Network where the height/width needs to be dynamic for a responsive layout.
If I set the Network to a fixed height/width all works as expected, except resizing (obviously) won't change the canvas to fit.
But if I set height/width to 100%, the canvas correctly sizes to the width (including autoResize set to true) but I always end up with a 150px height canvas, whereas the height of the container div could comfortably be > 800px.
I've created a demo plunker to show the problem.
The text was updated successfully, but these errors were encountered: