Skip to content

feat(charts): auto-enable mixed colors when color_negative is set#474

Merged
palewire merged 2 commits intochekos:mainfrom
palewire:main
Oct 21, 2025
Merged

feat(charts): auto-enable mixed colors when color_negative is set#474
palewire merged 2 commits intochekos:mainfrom
palewire:main

Conversation

@palewire
Copy link
Copy Markdown
Collaborator

Add model validator to AreaFill that automatically enables use_mixed_colors when a non-default color_negative value is provided. This improves UX by eliminating the need for users to manually enable the flag when they want to use negative colors, making the feature work as expected out of the box.

The validator only triggers when color_negative differs from the default "#cc0000" and use_mixed_colors is currently False.

For #459

Add model validator to AreaFill that automatically enables use_mixed_colors
when a non-default color_negative value is provided. This improves UX by
eliminating the need for users to manually enable the flag when they want
to use negative colors, making the feature work as expected out of the box.

The validator only triggers when color_negative differs from the default
"#cc0000" and use_mixed_colors is currently False.

For chekos#459
@palewire palewire requested a review from Copilot October 21, 2025 16:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR automatically enables the use_mixed_colors flag when users provide a custom color_negative value in the AreaFill class, improving user experience by eliminating manual configuration steps.

Key Changes:

  • Added a model validator to automatically set use_mixed_colors=True when a non-default color_negative is provided
  • Imported model_validator from pydantic to support this functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread datawrapper/charts/annos.py Outdated
Update AreaFill model to accept both hex strings and palette indices for
color fields. Changes include:

- Allow `color` field to accept int (palette index) or str (hex color)
- Change default `color` from "#15607a" to 0 (first palette color)
- Allow `color_negative` to accept int, str, or None
- Change default `color_negative` from "#cc0000" to None (disabled)
- Update auto-enable logic to check for None instead of default hex value
- Only serialize `colorNegative` when explicitly set (not None)
- Update field descriptions to reflect new behavior

This provides more flexibility for users to reference theme palette colors
by index while maintaining backward compatibility with hex color strings.
@palewire palewire requested a review from Copilot October 21, 2025 16:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

datawrapper/charts/annos.py:1

  • Changing the default from \"#cc0000\" to None is a breaking change. Existing code that relied on the implicit red color for negative values will now get no negative color unless explicitly set. This contradicts the PR description which states the validator 'only triggers when color_negative differs from the default "#cc0000"', but that default no longer exists.
from typing import Any, Literal

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread datawrapper/charts/annos.py
@palewire palewire merged commit 1b754fc into chekos:main Oct 21, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants