Bokeh line chart is disappearing on Mouse hover

I have developed Bokeh line chart , however on mouse hover the line chart is disappearing.

Libraries used
Streamlit 1.7.0
Bokeh 2.4.1

Minimal, Reproducible Example -

import streamlit as st
from bokeh.models import HoverTool, ColumnDataSource,DateFormatter, NumberFormatter
from bokeh.plotting import figure, output_file, show
from numpy import source
import pandas as pd
import numpy as np



if __name__ == '__main__':   

    year = [1960, 1970, 1980, 1990, 2000, 2010]
    pop_pakistan = [44.91, 58.09, 78.07, 107.7, 138.5, 170.6]
    pop_india = [449.48, 553.57, 696.783, 870.133, 1000.4, 1309.1]

    output_file('line.html', mode='inline')
    plot = figure(title='Population Graph of Sweden and Austria', x_axis_label='Year',
                  y_axis_label='Population in million')

    source_pk = ColumnDataSource(data=dict(
        year=year,
        population=pop_pakistan,
    ))

    source_in = ColumnDataSource(data=dict(
        year=year,
        population=pop_india,
    ))

    hover = HoverTool()
    hover.tooltips = """
    <div style=padding=5px>Year:@year</div>
    <div style=padding=5px>Population:@population</div>
    """
    plot.add_tools(hover)

    plot.line('year', 'population', line_width=2, line_color='green', legend_label='Sweden', source=source_pk)
    plot.circle('year', 'population', fill_color="green", line_color='green', size=8, source=source_pk)

    plot.line('year', 'population', line_width=2, line_color='orange', legend_label='Austria', source=source_in)
    plot.circle('year', 'population', fill_color="orange", line_color='orange', size=8, source=source_in)
    st.bokeh_chart(plot)

Help is really appreciated.

Regards,
John

Hi @John123 please edit your post to use code formatting so that the code is intelligible (either with the </> icon on the editing toolbar, or triple backtick ``` fences around the code blocks)

Also can you provide a Minimal Reproducible Example that is pure Bokeh (i.e. no streamlit)? If that’s not possible, then that is important information, and if it is possible, that makes it much easier for other people to help you.

@Bryan Please refer below code i.e. pure Bokeh


from bokeh.models import HoverTool, ColumnDataSource,DateFormatter, NumberFormatter
from bokeh.plotting import figure, output_file, show
from numpy import source
import pandas as pd
import numpy as np



if __name__ == '__main__':

    year = [1960, 1970, 1980, 1990, 2000, 2010]
    pop_pakistan = [44.91, 58.09, 78.07, 107.7, 138.5, 170.6]
    pop_india = [449.48, 553.57, 696.783, 870.133, 1000.4, 1309.1]

    output_file('line.html', mode='inline')
    plot = figure(title='Population Graph of Sweden and Austria', x_axis_label='Year',
                  y_axis_label='Population in million')

    source_pk = ColumnDataSource(data=dict(
        year=year,
        population=pop_pakistan,
    ))

    source_in = ColumnDataSource(data=dict(
        year=year,
        population=pop_india,
    ))

    hover = HoverTool()
    hover.tooltips = """
    <div style=padding=5px>Year:@year</div>
    <div style=padding=5px>Population:@population</div>
    """
    plot.add_tools(hover)

    plot.line('year', 'population', line_width=2, line_color='green', legend_label='Sweden', source=source_pk)
    plot.circle('year', 'population', fill_color="green", line_color='green', size=8, source=source_pk)

    plot.line('year', 'population', line_width=2, line_color='orange', legend_label='Austria', source=source_in)
    plot.circle('year', 'population', fill_color="orange", line_color='orange', size=8, source=source_in)
    
    show(plot)

Any Update on this issue? Even I see the same issue particularly when another layer (circle, square) added on top of line. I don’t see this issue in bokeh==2.0.2

I don’t see any issue with Bokeh 2.4.2 or with dev branch-3.0

Thanks for the response @Bryan
Streamlit 1.7 and 1.8 only supports Bokeh version 2.4.1
Can you please confirm why Streamlit 2.4.1 has the issue with the line plot thing on hovering?

For bokeh versions after 2.4.1, there’s a compatibility issue with Streamlit

That seems somewhat suprising, but I am afraid I don’t have any suggestions beyond using a different version, since this seems it to be a bug in 2.4.1.