import panel as pn
import holoviews as hv
df = pd.read_csv('https://raw.githubusercontent.com/miura/NEUBIAS_AnalystSchool2020/master/Arianne/Dataset/grant_complete.csv')
df.head()
#df['year'].unique() --> array([1973, 1975, 1987, 1991, 2012], dtype=int64)
df_2012 = df.loc[df['year']==2012, :].copy()
df_1973 = df.loc[df['year']==1973, :].copy()
df_1987 = df.loc[df['year']==1987, :].copy()
df_1991 = df.loc[df['year']==1991, :].copy()
point1= hv.Points(
data=df_2012,
kdims=['beak length (mm)', 'beak depth (mm)'],
vdims=['species'],
)
point2 = hv.Points(
data=df_1973,
kdims=['beak length (mm)', 'beak depth (mm)'],
vdims=['species'],
)
point3 = hv.Points(
data=df_1987,
kdims=['beak length (mm)', 'beak depth (mm)'],
vdims=['species'],
)
point4 = hv.Points(
data=df_1991,
kdims=['beak length (mm)', 'beak depth (mm)'],
vdims=['species'],
)
images = [point1, point2, point3, point4]
# define a Panel widget to display the current image
image_widget = pn.panel(images[0])
def next_image(event):
current_index = images.index(image_widget.object)
next_index = (current_index + 1) % len(images)
image_widget.object = images[next_index]
def prev_image(event):
current_index = images.index(image_widget.object)
prev_index = (current_index - 1) % len(images)
image_widget.object = images[prev_index]
next_button = pn.widgets.Button(name='Next', button_type='primary')
next_button.on_click(next_image)
prev_button = pn.widgets.Button(name='Previous',button_type='primary')
prev_button.on_click(prev_image)
obj = pn.Column(image_widget, pn.Row(prev_button, next_button))
obj
#obj.save("example.html") -> saving it to html
If I am launching this application from jupyter it's working as expected, i.e on clicking on next and previous button the points are rendered accordingly
But when I am trying to save it as html
obj.save("example.html"),
in the output the click events on previous and next is not working. the points are not rendered accordingly, on bydefault the images[0], i.e p1 is rendered
Would any one please help on this ? I have already tried like bokeh serve and panel serve the application , still the result is same.