diff --git a/ete4/smartview/faces.py b/ete4/smartview/faces.py index eb695d04f..a8f5fa810 100644 --- a/ete4/smartview/faces.py +++ b/ete4/smartview/faces.py @@ -271,11 +271,12 @@ def draw(self, nodes, size, collapsed, zoom=(1, 1), ax_ay=(0, 0), r=1): class PolygonFace(Face): """A polygon.""" - def __init__(self, rmax=None, shape=3, style='', - position='top', column=0, anchor=None): + def __init__(self, rmax=None, shape=3, rotation=0, + style='', position='top', column=0, anchor=None): super().__init__(position, column, anchor) self.shape = shape # name of the shape or number of edges + self.rotation = rotation # rotation in degrees self.rmax = rmax # maximum "radius" in pixels self.style = style @@ -295,7 +296,7 @@ def draw(self, nodes, size, collapsed, zoom=(1, 1), ax_ay=(0, 0), r=1): # Return the graphic and its size. center = (cr / zx, cr / (r * zy)) # in tree coordinates - polygon = gr.draw_polygon(center, cr, self.shape, self.style) + polygon = gr.draw_polygon(center, cr, self.shape, self.rotation, self.style) return [polygon], Size(2*cr/zx, 2*cr/(r*zy)) # NOTE: For small r (in circular mode), that size is just approximate. diff --git a/ete4/smartview/graphics.py b/ete4/smartview/graphics.py index b2f85885b..da3f3807b 100644 --- a/ete4/smartview/graphics.py +++ b/ete4/smartview/graphics.py @@ -65,8 +65,8 @@ def draw_arc(p1, p2, style=''): def draw_circle(center, radius=1, style=''): return ['circle', center, radius, style] -def draw_polygon(center, radius, shape=3, style=''): - return ['polygon', center, radius, shape, style] +def draw_polygon(center, radius, shape=3, rotation=0, style=''): + return ['polygon', center, radius, shape, rotation, style] def draw_box(box, style=''): return ['box', box, style] diff --git a/ete4/smartview/static/js/draw.js b/ete4/smartview/static/js/draw.js index f7ec04439..8bd8d19d8 100644 --- a/ete4/smartview/static/js/draw.js +++ b/ete4/smartview/static/js/draw.js @@ -289,8 +289,8 @@ function translate(item, shift) { return ["circle", [x + shift, y], radius, style]; } else if (item[0] === "polygon") { - const [ , [x, y], radius, shape, style] = item; - return ["polygon", [x + shift, y], radius, shape, style]; + const [ , [x, y], radius, shape, rotation, style] = item; + return ["polygon", [x + shift, y], radius, shape, rotation, style]; } else if (item[0] === "box") { const [ , box, style] = item; @@ -433,6 +433,7 @@ function legend2html(legend) { } else { // variable continuous: use value range and color range const [vmin, vmax] = vrange.map(format_number); // values + return header + `${vmax}