Defines the DataLabel class and related trait and function.
DataLabel(component=None, *args, **kw)¶
A label on a point in data space.
Optionally, an arrow is drawn to the point.
The color of the arrow.
The maximum length of the arrow before it will be drawn. By default, the arrow will be drawn regardless of how long it is.
The minimum length of the arrow before it will be drawn. By default, the arrow will be drawn regardless of how short it is.
arrow_root= Enum("auto", "top left", "top right", "bottom left", …¶
The position of the base of the arrow on the label. If this is ‘auto’, then the label uses label_position. Otherwise, it treats the label as if it were at the label position indicated by this attribute.
The length of the arrowhead, in screen points (e.g., pixels).
arrow_visible= Bool(True) # FIXME: replace with some sort of ArrowStyle¶
Draw an arrow from the label to the data point? Only used if data_point is not None.
Does the label clip itself against the main plot area? If not, then the label draws into the padding area (where axes typically reside).
The radius (in screen coordinates) of the curved corners of the “bubble”
The symbol to use if marker is set to “custom”. This attribute must be a compiled path for the given Kiva context.
The point in data space where this label should anchor itself.
label_format= Str("(%(x)f, %(y)f)")¶
The format string that determines the label’s text. This string is formatted using a dict containing the keys ‘x’ and ‘y’, corresponding to data space values.
The location of the data label relative to the data point.
label_style= Enum('box', 'bubble')¶
‘box’ is a simple rectangular box, with an arrow that is a single line with an arrowhead at the data point. ‘bubble’ can be given rounded corners (by setting corner_radius), and the ‘arrow’ is a thin triangular wedge with its point at the data point. When label_style is ‘bubble’, the following traits are ignored: arrow_size, arrow_color, arrow_root, and arrow_max_length.
The text to show on the label, or above the coordinates for the label, if show_label_coords is True
The type of marker to use. This is a mapped trait using strings as the keys.
The color of the inside of the marker.
The color out of the border drawn around the marker.
The thickness, in pixels, of the outline to draw around the marker. If this is 0, no outline will be drawn.
The pixel size of the marker (doesn’t include the thickness of the outline).
Mark the point on the data that this label refers to?
overlay(component, gc, view_bounds=None, mode='normal')¶
Draws the tooltip overlaid on another component.
Overrides and extends ToolTip.overlay()
Flag whether to show coordinates with the label or not.
xmid= Property(Float, observe=['x', 'x2'])¶
The center x position (average of x and x2)
ymid= Property(Float, observe=['y', 'y2'])¶
The center y position (average of y and y2)
draw_arrow(gc, pt1, pt2, color, arrowhead_size=10.0, offset1=0, offset2=0, arrow=None, minlen=0, maxlen=inf)¶
Renders an arrow from pt1 to pt2. If gc is None, then just returns the arrow object.
gc (graphics context) – where to render the arrow
pt1 (point) – the origin of the arrow
pt2 (point) – where the arrow is pointing
color (a 3- or 4-tuple of color value) – the color to use for the arrow stem and head
arrowhead_size (number) – screen units corresponding to the length of the arrowhead
offset1 (number) – the amount of space from the start of the arrow to pt1
offset2 (number) – the amount of space from the tip of the arrow to pt2
arrow (object) – an opaque object returned by previous calls to draw_arrow. If this argument is provided, all other arguments (except gc) are ignored
minlen (number or None) – the minimum length of the arrow; if the arrow is shorter than this, it will not be drawn
maxlen (number or None) – the maximum length of the arrow; if the arrow is longer than this, it will not be drawn
An ‘arrow’ (opaque object) which can be passed in to subsequent
calls to this method to short-circuit some of the computation.
Even if an arrow is not drawn (due to minlen/maxlen restrictions),
an arrow will be returned.
find_region(px, py, x, y, x2, y2)¶
Classify the location of the point (px, py) relative to a rectangle.
(x, y) and (x2, y2) are the lower-left and upper-right corners of the rectangle, respectively. (px, py) is classified as “left”, “right”, “top”, “bottom” or “inside”, according to the following diagram:
- top / # noqa
- / # noqa
+———-+ # noqa
- left | inside | right # noqa
+———-+ # noqa
/ # noqa
/ bottom # noqa