# WiggleColor

Auto-generated from the config schema in the source. See the [config guide](https://jbrowse.org/jb2/docs/config_guide) for concepts. Provided by the `wiggle` plugin. [View source](https://github.com/GMOD/jbrowse-components/blob/main/plugins/wiggle/src/shared/wiggleColorConfigSchema.ts).

The quantitative display's `encoding.color`: one CSS color for every mark,
the plotted score through a scale, or each subtrack in its row color.
`field` is `score`, which stands for the plotted value whatever field `y`
names, or `source`, the subtrack.

- `threshold` paints a solid color each side of one cut, the `origin`
  where `scale.domain` names none, and a color per band where it names
  more, on every mark
- `linear` paints a gradient across the y domain, through the y scale's
  own type: each bar, point and density cell by its score, and a line by
  the score along it
- unset `scale.type`, a two-color `scale.range` (red and blue unset) is the
  pair about the `origin`: bars, points and lines solid either side of it,
  and a heatmap (`mark: 'rect'`) fading to each from white at it, a ramp
  whose middle stop `scale.domainMid` moves

`source` paints each subtrack its row color, its `rows.colors` entry, else the
file's `color`, else a palette color where several share one plot, on both
sides of the `origin`; a subtrack with none paints the score's pair. A
color writing nothing does the same on bars, points and lines, so a lone
BigWig keeps its pair, and a heatmap ramps the score. A wiggle colors per
signal rather than per feature, so a `jexl:` callback over a feature has
nothing to read here.

## Example usage

```js
{ type: 'LinearWiggleDisplay', encoding: { color: { value: 'darkgreen' } } }
```

```js
{
  type: 'LinearWiggleDisplay',
  encoding: {
    color: {
      scale: { type: 'threshold', domain: [2], range: ['#2166ac', '#b2182b'] },
    },
  },
}
```

```js
{
  type: 'LinearWiggleDisplay',
  mark: 'rect',
  encoding: { color: { scale: { type: 'linear', scheme: 'viridis' } } },
}
```

Subtracks in their row colors, as they paint while `encoding.color` is
unset:

```js
{ type: 'LinearWiggleDisplay', encoding: { color: 'source' } }
```

A copy-number heatmap, white at two copies, blue losses and red gains:

```js
{
  type: 'LinearWiggleDisplay',
  mark: 'rect',
  origin: 2,
  encoding: { color: { scale: { range: ['#2166ac', '#b2182b'] } } },
}
```

## Preset fields

A `field` named here paints through its own scale while `scale.type` is unset, and `range` and `names` index its levels in order while `domain` is unwritten. Any other field is threshold.

| Field | Scale | Levels | Names | Other defaults |
| --- | --- | --- | --- | --- |
| `source` | ordinal |  |  |  |

## Config slots

A setting written to it replaces it whole: a member left out returns to its default. Slot types (`fileLocation`, `frozen`, ...) are explained in the [config slot types reference](https://jbrowse.org/jb2/docs/config_guides/slot_types). Slots a base configuration contributes are listed here too, so this table is the whole surface.

| Slot | Description |
| --- | --- |
| **field**<br>[`stringEnum`](https://jbrowse.org/jb2/docs/config_guides/slot_types#stringenum) ("", score, source) = <code>''</code> | `score` for the plotted value, through `scale`; `source` for each subtrack's row color, which reads no `scale`. Unset, a color writing a `scale` maps `score`, and one writing nothing maps `source` on bars, points and lines and `score` on a heatmap. |
| **value**<br>[`maybeColor`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | One CSS color for every mark, a density cell included, so a heatmap under one is a flat strip. Unset, the display paints the pair about the `origin`, and several sources sharing one plot box each paint their row color. |
| **scale**<br>[WiggleColorScale sub-schema](#slot-scaletype) | The scale from the score to a color. `threshold` paints each band between two of its cuts, solid, on every mark; `linear` runs `range`, else `scheme`, else viridis across the y domain through `encoding.y.scale.type`, with `domainMid` at the middle stop, coloring each bar, point and density cell by its score; a one-color `range` paints flat, so one color is `value`. With `type` unset, `range` is the pair about the `origin`: a threshold on bars, points and lines, and on a heatmap a ramp through white at the origin. |
| **legend**<br>[WiggleColorLegend sub-schema](#slot-legendtitle) | The key this channel draws. No `descending`: wiggle builds its own threshold key around its cuts (Colin, 2026-10-30). |
| **scale.type**<br>[`maybeStringEnum`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) (linear, threshold) | threshold bands score at the domain cuts, solid on every mark, linear ramps it across the y domain; unset, range is the pair about the origin, solid on bars, points and lines and fading from white there on a heatmap |
| **scale.domain**<br>[`stringArray`](https://jbrowse.org/jb2/docs/config_guides/slot_types#stringarray) = <code>[]</code> | for a threshold scale, up to eight cut points, sorted, empty meaning one at the origin |
| **scale.range**<br>[`colorArray`](https://jbrowse.org/jb2/docs/config_guides/slot_types#colorarray) = <code>[]</code> | a threshold scale's color for each band, lowest first, one more than the cuts, a missing middle band grey; a linear scale's stops, evenly spaced, one color painting flat |
| **scale.scheme**<br>[`maybeStringEnum`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) (viridis, magma, inferno, cividis, juicebox, fall, reds, blues, redblue, purpleorange, redgreyblue, redyellowblue) | a named ramp: a ramp scale colors along it; a threshold scale that writes cuts gives each interval one color from end to end; an ordinal scale that lists a domain gives each value one color; range's colors, where it lists any, win over it |
| **scale.reverse**<br>[`maybeBoolean`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | turns the ramp round, so its last color paints the bottom of a ramp's domain or a threshold's lowest interval; unset follows the field's preset, else runs as written |
| **scale.domainMid**<br>[`maybeNumber`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | the value the ramp's middle stop sits at, so a diverging ramp centres somewhere other than the middle of the domain, both sides on one scale: the farther end of the domain reaches its end color and equal distances from the middle take equal colors; unset, the stops are evenly spaced across it |
| **scale.names**<br>[`stringArray`](https://jbrowse.org/jb2/docs/config_guides/slot_types#stringarray) = <code>[]</code> | key name for each domain value, one each in order, or under threshold for each interval from the lowest; a value past the end of the list shows its own |
| **legend.title**<br>[`maybeString`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | key title; unset keeps the display's own heading, "" draws none |

