Add automatic contrast-aware colouring for annotations in Displayr visualizations
B
Belinda Bailey
Currently, data labels in Displayr support automatic contrast-aware font coloring via
data.label.font.autocolor
, which ensures readability by dynamically adjusting text color based on the background.However, annotations (via
annotation.list
and overlay.annotation.list
in CChart()
) only support a fixed color
parameter. This creates behavioral inconsistencies and can lead to readability issues when annotations are placed over varying chart colors.Requested enhancement:
Introduce support for automatically coloring annotations, with functionality equivalent to that of data labels. This could include:
- A parameter such as:
-
annotation.font.autocolor = TRUE
- Or default behavior where annotation text automatically adjusts for contrast when no explicit color is set
Benefits:
- Improved readability and accessibility
- Consistency between annotations and data labels
- Reduced need for manual formatting when chart palettes change
- Better support for dynamic / template-driven reporting
Example use case:
In charts where data labels automatically switch between light/dark text depending on fill color, annotations currently remain fixed (e.g., always black), making them hard to read on darker backgrounds. Matching this behavior would resolve the issue.
Technical context:
Annotations are currently defined via:
```r
annotation.list = list(
list(type = ..., data = ..., color = ...)
)