@@ -11,8 +11,24 @@ typealias AnnotationOptions = layerLabels
1111
1212
1313/* *
14- * Configures annotations (for pie chart).
15- * Defines the content and format for displaying the value.
14+ * Configure annotations for geometry layers.
15+ *
16+ * Annotations are currently supported for bar, pie, and crossbar geometry
17+ * layers. This class provides methods to customize the appearance and
18+ * content of text labels displayed on these geometries.
19+ *
20+ * Notes
21+ * -----
22+ * By default, annotation text color is automatically selected for optimal
23+ * contrast: white text appears on darker filled geometries, and black text
24+ * appears on lighter filled geometries.
25+ *
26+ * The text color can be manually specified using:
27+ * ``theme(labelText=elementText(color=...))``
28+ *
29+ * Alternatively, the ``inheritColor()`` method can be used to override both
30+ * automatic and manual color settings, making the annotation text use the
31+ * geometry's ``color`` aesthetic instead.
1632 *
1733 * ## Examples
1834 *
@@ -121,12 +137,17 @@ class layerLabels(vararg variables: String) {
121137 return setOption(ANNOTATION_SIZE , value)
122138 }
123139
140+ fun inheritColor (): layerLabels {
141+ return setOption(USE_LAYER_COLOR , true )
142+ }
143+
124144 private companion object {
125145 private const val VARIABLES = Option .LinesSpec .VARIABLES
126146 private const val FORMATS = Option .LinesSpec .FORMATS
127147 private const val FIELD = Option .LinesSpec .Format .FIELD
128148 private const val FORMAT = Option .LinesSpec .Format .FORMAT
129149 private const val LINES = Option .LinesSpec .LINES
130150 private const val ANNOTATION_SIZE = Option .AnnotationSpec .ANNOTATION_SIZE
151+ private const val USE_LAYER_COLOR = Option .AnnotationSpec .USE_LAYER_COLOR
131152 }
132153}
0 commit comments