I’m trying to create a Bars plot that displays the value counts of the currently visible points on a map. Well, it’s a bit more advaced, because the Points linked in RangeXY are not necessarily displayed, as they are used as a source to create a hd.datashade if zoomed out.
What I have looks like it’s working at first glance, the bars change when I zoom the map in and out, but then the bars show flickering zero values, and also the datashaded points (and sometimes even other overlaid images) keep disappearing:
Sometimes it’s even constantly flickering:
If I comment out the function with the bars, everything works normally.
This is how my relevant code looks like:
original_wpc_hv_points = hv.Points(wp, ['easting', 'northing']).apply(...)
streams = [hv.streams.RangeXY(source=original_wpc_hv_points)]
def get_points_in_viewport(original_points, x_range, y_range):
if x_range is None or y_range is None:
return original_points
else:
points_in_range = original_points[x_range, y_range]
return points_in_range
points_in_viewport = original_wpc_hv_points.apply(
get_points_in_viewport, streams=streams
)
def get_wp_statuses_bars(points_in_viewport):
df = pd.DataFrame(points_in_viewport.data['cutoff_status_latest_result']\
.value_counts().rename('Count')).reset_index(level=0)
df.rename(columns={"index": "Latest Status"}, inplace=True)
print(df)
bars = hv.Bars(df, hv.Dimension('Latest Status'), 'Count').opts(
invert_axes=True, color='Latest Status', show_legend=False,
height=120, toolbar=None, ylabel='', cmap=wp_category_color_dict_status)
return bars
wp_statuses_bars = points_in_viewport.apply(get_wp_statuses_bars)
The print statements for the flickering example gives me this in a loop:
...
Latest Status Count
0 Functional 0
1 Needs repair 0
2 Not functional 0
3 Unknown 0
Latest Status Count
0 Functional 9413
1 Needs repair 4435
2 Not functional 2877
3 Unknown 2485
Latest Status Count
0 Functional 0
1 Needs repair 0
2 Not functional 0
3 Unknown 0
Latest Status Count
0 Functional 9862
1 Needs repair 4486
2 Not functional 2915
3 Unknown 2715
Latest Status Count
0 Functional 0
1 Needs repair 0
2 Not functional 0
3 Unknown 0
...
Does anybody have an idea why this is happening and/or what’s the ideal way to achieve the same result without this issue? Thanks.