pyvis icon indicating copy to clipboard operation
pyvis copied to clipboard

Selection and filtering menu support in UTF-8 [experimental branch]

Open yanirmr opened this issue 2 years ago • 2 comments

I find this package and the experimental branch to be extremely useful, and I appreciate its aesthetic appeal both visually and technologically. I believe I have discovered an issue with the selection menu in the experimental branch. The selection menu does not display words that contain UTF-8 characters, such as Hebrew and Arabic words. But, and this surprises me, the filtering tool worked. Perhaps there is a nuance in the way they represent the characters that cause this inconsistency.

Here is a mini example that can be used to reproduce the bug:

The first case (selection):

from pyvis.network import Network

net = Network(height="750px", width="100%", bgcolor="#222222", font_color="white",
                  select_menu=True)
net.add_nodes(['אברהם', 'שרה'])
net.add_edge('אברהם', 'שרה')
net.show('select.html')

The second case (filtering):

from pyvis.network import Network

net = Network(height="750px", width="100%", bgcolor="#222222", font_color="white",
                  filter_menu=True)
net.add_nodes(['אברהם', 'שרה'])
net.add_edge('אברהם', 'שרה')
net.show('filter.html')

The second case works as expected, while the first case displays the words as ????-??? image

image

@js-konda @BerserkerGaruk WDYT? Thank you!

yanirmr avatar Sep 23 '22 09:09 yanirmr

While I am not a JS expert, I suspect that the following line in templates.html does not fulfill its purpose:

                                {% for node in nodes %}
                                    <option value="{{ node.id }}">{{node.id}}</option>
                                {% endfor %}

I would appreciate your assistance in this matter.

yanirmr avatar Sep 25 '22 07:09 yanirmr

with open(getcwd_name, "w+",encoding='utf-8') as out:
            out.write(self.html)
    elif self.cdn_resources == "in_line" or self.cdn_resources == "remote":
        with open(getcwd_name, "w+",encoding='utf-8') as out:
            out.write(self.html)

xeon-ye avatar Nov 07 '23 00:11 xeon-ye