WestHealth / pyvis

Python package for creating and visualizing interactive network graphs.
http://pyvis.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
975 stars 165 forks source link

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

Open yanirmr opened 1 year ago

yanirmr commented 1 year ago

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 commented 1 year ago

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.

xeon-ye commented 10 months ago
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)