in chartify/_core/callout.py [0:0]
def box(self, top=None, bottom=None, left=None, right=None, alpha=0.2, color="red"):
"""Add box callout to the chart.
Args:
top (numeric, optional): Top edge of the box.
bottom (numeric, optional): Bottom edge of the box.
left (numeric, optional): Left edge of the box.
right (numeric, optional): Right edge of the box.
alpha (float, optional): 0.2
color (str): Color name or hex value.
See chartify.color_palettes.show() for available color names.
Note:
The box will extend to the edge if the corresponding position
argument is omitted.
Returns:
Current chart object
"""
# Convert datetime values to epoch if datetime axis.
if isinstance(self._chart.axes, DatetimeXNumericalYAxes):
if left is not None:
left = self._chart.axes._convert_timestamp_to_epoch_ms(left)
if right is not None:
right = self._chart.axes._convert_timestamp_to_epoch_ms(right)
color = colors.Color(color).get_hex_l()
box = bokeh.models.BoxAnnotation(
top=top,
bottom=bottom,
left=left,
right=right,
fill_alpha=alpha,
fill_color=color,
)
self._chart.figure.add_layout(box)
return self._chart