Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support BoxAnnotation's new API Bokeh 3.3 #5935

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion holoviews/plotting/bokeh/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ class BoxAnnotationPlot(ElementPlot, AnnotationPlot):
selection_display = None

def get_data(self, element, ranges, style):
data, mapping = {}, {}
data = {}
mapping = {k: None for k in ('left', 'right', 'bottom', 'top')}
kwd_dim1 = 'left' if isinstance(element, VSpan) else 'bottom'
kwd_dim2 = 'right' if isinstance(element, VSpan) else 'top'
if self.invert_axes:
Expand Down
38 changes: 28 additions & 10 deletions holoviews/tests/plotting/bokeh/test_annotationplot.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import unittest

import numpy as np
import pandas as pd

import holoviews as hv
from holoviews.element import (
HLine, VLine, Text, Labels, Arrow, HSpan, VSpan, Slope,
HLines, VLines, HSpans, VSpans,
)
from holoviews.plotting.bokeh.util import bokeh32
from holoviews.plotting.bokeh.util import bokeh32, bokeh33

from .test_plot import TestBokehPlot, bokeh_renderer

if bokeh32:
from bokeh.models import VSpan as BkVSpan, HSpan as BkHSpan, VStrip as BkVStrip, HStrip as BkHStrip

if bokeh33:
from bokeh.models.coordinates import Node


class TestHVLinePlot(TestBokehPlot):

Expand Down Expand Up @@ -56,16 +58,24 @@ def test_hspan_invert_axes(self):

assert span.left == 1.1
assert span.right == 1.5
assert pd.isna(span.bottom)
assert pd.isna(span.top)
if bokeh33:
assert isinstance(span.bottom, Node)
assert isinstance(span.top, Node)
else:
assert span.bottom is None
assert span.top is None
assert span.visible

def test_hspan_plot(self):
hspan = HSpan(1.1, 1.5)
plot = bokeh_renderer.get_plot(hspan)
span = plot.handles['glyph']
assert pd.isna(span.left)
assert pd.isna(span.right)
if bokeh33:
assert isinstance(span.left, Node)
assert isinstance(span.right, Node)
else:
assert span.left is None
assert span.right is None
assert span.bottom == 1.1
assert span.top == 1.5
assert span.visible
Expand All @@ -80,8 +90,12 @@ def test_vspan_invert_axes(self):
vspan = VSpan(1.1, 1.5).opts(invert_axes=True)
plot = bokeh_renderer.get_plot(vspan)
span = plot.handles['glyph']
assert pd.isna(span.left)
assert pd.isna(span.right)
if bokeh33:
assert isinstance(span.left, Node)
assert isinstance(span.right, Node)
else:
assert span.left is None
assert span.right is None
assert span.bottom == 1.1
assert span.top == 1.5
assert span.visible
Expand All @@ -92,8 +106,12 @@ def test_vspan_plot(self):
span = plot.handles['glyph']
assert span.left == 1.1
assert span.right == 1.5
assert pd.isna(span.bottom)
assert pd.isna(span.top)
if bokeh33:
assert isinstance(span.bottom, Node)
assert isinstance(span.top, Node)
else:
assert span.bottom is None
assert span.top is None
assert span.visible

def test_vspan_empty(self):
Expand Down