Skip to content

Commit 3769ce6

Browse files
Add inheritColor()
1 parent a55bb49 commit 3769ce6

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

future_changes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ GeoTools [v 33.2](https://github.com/geotools/geotools/releases/tag/33.2)
88
- Geometries:
99
- `geomTextRepel()` and `geomLabelRepel()` [[#1092](https://github.com/JetBrains/lets-plot/issues/1092)].
1010
See: [example notebook](https://nbviewer.org/github/JetBrains/lets-plot-kotlin/blob/master/docs/examples/jupyter-notebooks/f-4.11.0/ggrepel.ipynb).
11+
- Layer Labels (Annotations):
12+
13+
- New `inheritColor()` option in annotations configuration (see example notebooks above)
1114

1215
- Plot Layout:
1316

plot-api/src/commonMain/kotlin/org/jetbrains/letsPlot/annotations/AnnotationOptions.kt

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)