Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

Network: HTML formatted text in nodes disappears after setting new options #3047

Closed
Steff1337 opened this issue May 11, 2017 · 7 comments
Closed

Comments

@Steff1337
Copy link

Hello,

i recently faced a problem while using the VisJS library. I created a network with some nodes that have HTML formatted text (bold and italic). That works fine so far, but when i change the options - e.g. to switch the direction of the network - the formatted part of the text dissapears.

I have setted up an example on jsfiddle.

The only workaround i found was calling the location.reload() method. But this only works if the options can be saved before the reload. In my case this works because i am using the library for a Vaadin addon which keeps the state inside a java object. If somebody knows a better solution i would be very pleased :). Reloading the whole page works this way but may be confusing to the user.

Thanks in advanced.

Regrads,

Steff

@wimrijnders
Copy link
Contributor

After some intensive debugging, I discovered that in the internal representation, field vadjust becomes undefined for any texts within tags. Because of this, the draw fails for these blocks.

The next step is to discover why this happens. But I suppose that a check can be placed in the draw location (ref: Label.js method _drawText(), line 363) to prevent this from happening.

In any case: confirmed.

@wimrijnders
Copy link
Contributor

wimrijnders commented May 11, 2017

I can trace the problem all the way down to the missing of the vadjust field in variable defaultOptions in NodesHandler.js.

I'm sorry to report I have no easy fix for this. The problem is simple but sorting out how to fix it is non-trivial. The best fix I can offer you, is to re-pass the option definitions when you call setOptions().

Unless you got vis.js from the repo and built it yourself, of course. In that case, I can give you a simple two-line fix for this.

@wimrijnders
Copy link
Contributor

According to the doc vadjust for the special fonts:

Defaults to the base font's valign.

This would be in essence the issue here. It does not default to that value.

@wimrijnders wimrijnders changed the title Network: HTML formatted text in nodes dissapears after setting new options Network: HTML formatted text in nodes disappears after setting new options May 11, 2017
@Steff1337
Copy link
Author

Thanks again for your quick response :)

What do you mean by

re-pass the option definitions when you call setOptions()

Do you mean passing the whole options object with the changed values or do i have to pass something in addition?

Regards,

Steff

@wimrijnders
Copy link
Contributor

I've figured out a fix. Will make a PR soon.

@wimrijnders
Copy link
Contributor

Do you mean passing the whole options object with the changed values

Yes, that's what I meant. But I tried to verify this and, unfortunately, it doesn't work. The only way to get this working properly is to fix some code (Label.getFormattingValues()).

@Steff1337
Copy link
Author

Thanks again :)

I will wait for the release and use my workaround until then.

@mojoaxel mojoaxel added this to the Minor Release v4.20 milestone May 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants