rezaho / streamlit-wordcloud

MIT License
36 stars 9 forks source link

Refresh issue #2

Open GiorgioMand opened 3 years ago

GiorgioMand commented 3 years ago

I don't know if you already noticed, but whenever one plots a wordcloud the resulting streamlit page continuously refreshes. This of course invalidate any other filter, since they get restarted over and over.

roha99 commented 3 years ago

yeah this is a problem for me too

getmykhan commented 3 years ago

@rezaho ^^

yochail commented 2 years ago

I think this is caused by the nature of streamlit and the fact that the code is changing the state on each js "hover" or "click" event on the word cloud. Removing onWordClicked and onWordHovered from here will fix the issue, but will not allow for the state to affect the app state. I didn't needed the hover action it so i solved the problem by commenting out

  const onWordClicked = (word) => {
     setState((state) => {
       return {
         clicked: word,
         hovered: state.hovered,
       }
     });
  }
  const onWordHovered = (word) => {
    // setState((state) => {
    //   return {
    //    clicked: state.clicked,
    //     hovered: word,
    //   }
     })
  }

and rebuilding the js code, avoiding the refresh caused by the hover event. @rezaho you might consider to change this since it makes the code as is almost unusable

naraugialusru commented 2 years ago

@yochail Can you explain to me how to rebuild? I'm not familiar with javascript. So far, I've cloned rezaho/streamlit-wordcloud, and commented the lines you suggested.

sfc-gh-upatel commented 2 years ago

Would you please provide option to disable click and hover?

OliverJia118 commented 2 years ago

Could anyone please share some insight on how to disable hover please ~ Really Appreciated

vmoraa commented 1 year ago

Hello. How do I change the background color? I have tried many ways with no results.

flucas96 commented 1 year ago

I have added two paramters to the function:

ignore_hover ignore_click

If those are true nothing will be returned and streamlit wont reload the page.

https://pypi.org/project/streamlit-wordcloud-v2/

sfc-gh-upatel commented 1 year ago

I was testing this, but I got following error , I have both streamlit-wordcloud 0.1.0 and streamlit-wordcloud-v2 0.4.0

Using this way:

wordcloud.visualize(names, tooltip_data_fields={'text': 'keyword', 'value': 'Value', 'rank':'Rank'}, per_word_coloring=False, ignore_hover=True, height=500)

TypeError: visualize() got an unexpected keyword argument 'ignore_hover'

What is required to make it work?

kriskrishnaa commented 4 months ago

Hey @flucas96, thanks for your effort. The version 2 works just fine. Would you mind telling me how to disable word rotation or at least share you git source code setup for building the dist. It is really annoying to read the words when rotated.