open-webui-plugins icon indicating copy to clipboard operation
open-webui-plugins copied to clipboard

Pie/donut wedges render in a single flat color — c-* ramp classes don't cover <path>

Open opicron opened this issue 3 months ago • 1 comments

Summary

The injected ramp classes (c-blue, c-teal, …) only style rect, circle and ellipse. Any series drawn as a <path> or <polygon> — pie and donut wedges, area fills, arcs — gets no color from them, so every slice of a pie chart paints the same shade and the chart reads as uncolored.

Reproduce

Ask for a pie or donut chart of a few categories. The model follows the documented color contract and emits one group per slice:

<g class="c-blue"><path d="M 0 0 L 0 -120 A 120 120 0 0 1 104.9 58.3 Z" fill="currentColor"/></g>
<g class="c-teal"><path d="M 104.9 58.3 A 120 120 0 0 1 -13.9 119.2 L 0 0 Z" fill="currentColor"/></g>

All wedges come out identical: near-black in light mode, near-white in dark.

Cause

The ramp block defines exactly two rules per color:

.c-blue>rect,.c-blue>circle,.c-blue>ellipse{fill:var(--ramp-blue-fill);stroke:var(--ramp-blue-stroke);stroke-width:.5}
.c-blue>.th{fill:var(--ramp-blue-th)!important} .c-blue>.ts{fill:var(--ramp-blue-ts)!important}

There is no path or polygon selector anywhere, and no .c-* rule ever sets the CSS color property. So for a wedge:

  1. .c-blue>path matches nothing, and the element keeps its author fill="currentColor".
  2. currentColor resolves to the inherited CSS color, which the injected base stylesheet sets once on body as var(--color-text-primary).
  3. Every wedge in every group therefore resolves to the same value — the body text color — regardless of which ramp class wraps it.

[!TIP] The giveaway is that the legend swatches are correctly colored while the chart is not. Legend swatches are <rect> children of the same c-* groups, written with the same fill="currentColor"; there the CSS declaration wins over the presentation attribute and the ramp color applies. Same markup, same classes, only the element name differs.

[!IMPORTANT] This is unrecoverable from inside a conversation. Told the chart has no colors, the model can only re-emit fill="currentColor" or reach for literal hex values — and the documented contract explicitly forbids hardcoded colors because they don't follow the sandbox's runtime theme flip. There is no markup the model can write that colors a <path> through the ramp classes.

Fix

Two extra rules per ramp:

  .c-blue>rect,.c-blue>circle,.c-blue>ellipse{fill:var(--ramp-blue-fill);stroke:var(--ramp-blue-stroke);stroke-width:.5}
+ .c-blue{color:var(--ramp-blue-stroke)}
+ .c-blue>path:not([class]):not([fill]),.c-blue>polygon:not([class]):not([fill]){fill:var(--ramp-blue-stroke)}
  .c-blue>.th{fill:var(--ramp-blue-th)!important} .c-blue>.ts{fill:var(--ramp-blue-ts)!important}
  • The color: declaration makes fill="currentColor" and stroke="currentColor" resolve to the series color for any mark — path, polygon, polyline, marker — which is what the model reaches for by default.
  • The second rule covers marks authored with no fill attribute at all.

[!WARNING] Both guards on that second selector are load-bearing:

  • :not([class]) — a bare .c-blue>path would out-specify .arr{fill:none} (0,1,1 vs 0,1,0) and fill in connector arrows and leader lines as solid blobs whenever they appear inside a colored group.
  • :not([fill]) — a CSS fill declaration beats a presentation attribute, so an unguarded rule would override fill="none" on line and area-outline marks and flood them.

--ramp-*-stroke (the saturated end of the ramp) is the right value here rather than --ramp-*-fill. The *-fill tints are deliberately pale because they sit behind label text inside boxes; five pale tints in a donut are close to indistinguishable.

Also worth updating

The color contract in the visualize() docstring says data series are "bars, lines, slices" but only ever demonstrates <rect>, so nothing tells the model how a path mark is supposed to be colored. Suggested addition:

For <path> and <polygon> marks — pie/donut wedges, areas, arcs — either omit the fill attribute entirely or write fill="currentColor"; both resolve to that group's ramp color. Do NOT put fill="currentColor" outside a c-NAME group: currentColor then falls back to the body text color and every series paints the same shade. For line marks keep fill="none" and use stroke="currentColor".

The same sentence belongs in the result_context string returned by visualize(), which carries its own condensed copy of the contract.

Verification

Rendered the failing chart's exact SVG against the patched stylesheet in headless Chrome and read back getComputedStyle().fill per wedge:

before after (light) after (dark)
distinct wedge fills 1 / 5 5 / 5 5 / 5
Full computed-style dump after the patch
--- light ---
  w1     fill=rgb(24, 95, 165)       stroke=none
  w2     fill=rgb(15, 110, 86)       stroke=none
  w3     fill=rgb(153, 60, 29)       stroke=none
  w4     fill=rgb(133, 79, 11)       stroke=none
  w5     fill=rgb(83, 74, 183)       stroke=none
  sw     fill=rgb(230, 241, 251)     stroke=rgb(24, 95, 165)
  line   fill=none                   stroke=rgb(59, 109, 17)
  arrow  fill=none                   stroke=rgba(0, 0, 0, 0.3)
  distinct wedge fills: 5/5

--- dark ---
  w1     fill=rgb(133, 183, 235)     stroke=none
  w2     fill=rgb(93, 202, 165)      stroke=none
  w3     fill=rgb(240, 153, 123)     stroke=none
  w4     fill=rgb(239, 159, 39)      stroke=none
  w5     fill=rgb(175, 169, 236)     stroke=none
  sw     fill=rgb(12, 68, 124)       stroke=rgb(133, 183, 235)
  line   fill=none                   stroke=rgba(255, 255, 255, 0.3)
  distinct wedge fills: 5/5

w1–w5 are wedges (w5 authored with no fill attribute, to exercise the fallback rule), sw a legend swatch, line a <path fill="none" stroke="currentColor">, arrow a <path class="arr">.

No regressions in the same pass: legend <rect> keeps pale fill + saturated hairline, fill="none" line marks stay unfilled and pick up the ramp stroke, and .arr arrows are unchanged.

opicron avatar Aug 04 '26 07:08 opicron

fixed in dev, new release incoming

Classic298 avatar Aug 07 '26 18:08 Classic298