From b74d9b09e540b8f7022e84a2c9541b6a9b6bd8ef Mon Sep 17 00:00:00 2001 From: vrtornisiello Date: Wed, 16 Sep 2026 17:39:05 -0300 Subject: [PATCH] feat: simplify chart-spec color prompt Co-Authored-By: Claude Sonnet 5 --- app/charts.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/app/charts.py b/app/charts.py index d14a38f..00a33c6 100644 --- a/app/charts.py +++ b/app/charts.py @@ -62,14 +62,7 @@ ## Color -Do not set colors, scales, or ranges for a categorical or single-series encoding — just map a field to the color channel to distinguish series and leave the palette to the defaults. - -For a numeric value mapped to color (any mark colored by a number), set the color scale's `scheme` only when the value's semantic meaning has a color convention worth matching; otherwise leave it to the default. For example: - -- Temperature → blue for cold, red for hot: use "redblue" or "redyellowblue" (add `"reverse": true` if low and high land on the wrong ends). -- A quantity that diverges around a meaningful midpoint → a diverging scheme such as "redblue" or "blueorange" with the scale's `domainMid` set to that midpoint. - -When you do name a scheme, use a real Vega scheme name — never one from another library. Prefer colorblind-safe schemes. +Never set any color-related property — no `scale`, `scheme`, `sort`, `range`, or explicit color value — on any encoding, mark, or config, whether the field is categorical, quantitative, or there's only one series. Just map the field to the color channel and leave everything else about its color to the frontend's defaults. ## Number formatting @@ -106,7 +99,7 @@ "projection": {"type": "mercator"}, "mark": "geoshape", "encoding": { - "color": {"field": "valor", "type": "quantitative", "title": "…", "scale": {"scheme": "yellowgreenblue"}}, + "color": {"field": "valor", "type": "quantitative", "title": "…"}, "tooltip": [{"field": "properties.name", "type": "nominal", "title": "Estado"}, {"field": "valor", "type": "quantitative"}] }, } @@ -117,7 +110,7 @@ "projection": {"type": "mercator"}, "mark": "geoshape", "encoding": { - "color": {"field": "valor", "type": "quantitative", "title": "…", "scale": {"scheme": "yellowgreenblue"}}, + "color": {"field": "valor", "type": "quantitative", "title": "…"}, "tooltip": [{"field": "properties.name", "type": "nominal", "title": "Município"}, {"field": "valor", "type": "quantitative"}] }, }