# MarkColor

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 `marks` plugin. [View source](https://github.com/GMOD/jbrowse-components/blob/main/plugins/marks/src/LinearMarkDisplay/markColorConfigSchema.ts).

A mark's `encoding.color`: one CSS color or `jexl:` callback for every
instance in `value`, or a `field` through `scale`, Vega-Lite's scale
object: an ordinal scale (a `range` color per value), a `linear`, `log` or
`symlog` scale (a ramp between `domainMin` and `domainMax`, `domainMid`
placing its middle stop where a diverging ramp turns; `symlog` runs
logarithmic away from 0 and linear through it, so a signed fold change
ramps on both sides) or a `threshold` scale (a `range` color per interval
between the cut points `domain` lists). An `identity` scale paints each
feature the CSS color its `field` holds, or with no field the BED color it
carries. A string is the field, as
every channel's is inside `encoding`; a constant is `{ value }`. `legend`
shapes the key the scale draws.

## Example usage

```js
{ mark: 'bar', encoding: { y: 'score', color: { value: 'steelblue' } } }
```

```js
{ mark: 'point', encoding: { y: 'score', color: 'type' } }
```

```js
{
  mark: 'point',
  encoding: {
    y: 'score',
    color: { field: 'strand', scale: { domain: ['1', '-1'] } },
  },
}
```

```js
{
  mark: 'rect',
  encoding: {
    color: {
      field: 'score',
      scale: {
        type: 'log',
        domainMin: 1,
        domainMax: 1000,
        range: ['white', 'red'],
      },
    },
  },
}
```

```js
{
  mark: 'bar',
  encoding: {
    y: 'score',
    color: {
      field: 'score',
      scale: {
        type: 'linear',
        domainMin: -2,
        domainMax: 6,
        domainMid: 0,
        range: ['blue', 'white', 'red'],
      },
    },
  },
}
```

```js
{
  mark: 'point',
  encoding: {
    y: 'score',
    color: {
      field: 'pip',
      scale: {
        type: 'threshold',
        domain: [0.1, 0.5],
        range: ['#357ebd', '#eea236', '#d43f3a'],
      },
      legend: { title: 'PIP', descending: true },
    },
  },
}
```

```js
{
  mark: 'rect',
  encoding: {
    row: 'cellType',
    color: {
      scale: {
        type: 'identity',
        domain: ['rgb(255,0,0)', 'rgb(0,128,0)'],
        names: ['Active TSS', 'Strong transcription'],
      },
    },
  },
}
```

## 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 ordinal.

| Field | Scale | Levels | Names | Other defaults |
| --- | --- | --- | --- | --- |
| `strand` | ordinal | `1`, `-1`, `0` | Forward strand, Reverse strand, No strand | `range`: `tomato`, `cornflowerblue`, `goldenrod` |
| `svType` | ordinal | `DEL`, `DUP`, `INS`, `INV`, `CNV`, `TR`, `BND`, `CPX`, `OTHER` | Deletion, Duplication, Insertion, Inversion, Copy-number variable, Tandem repeat, Breakend / translocation, Complex, Other / mixed | `range`: `#e41a1c`, `#377eb8`, `#800080`, `#ff7f00`, `#7e6148`, `#e7298a`, `#17becf`, `#66a61e`, `#000000`; key "SV type" |
| `impact` | ordinal | `HIGH`, `MODERATE`, `LOW`, `MODIFIER`, `Unannotated` |  | `range`: `#d32f2f`, `#f57c00`, `#fbc02d`, `#9e9e9e`, `#607d8b`; key "Consequence impact" |
| `score` | linear |  |  |  |

## 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 |
| --- | --- |
| **value**<br>[`maybeColor`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | A CSS color, or a jexl callback over `feature` returning one, for a mark whose color is not a scale. Unset, a mark paints in the default blue, `#0068d1`, and a text mark prints in the page's text color.<br>_callback args:_ `feature` |
| **scale**<br>[MarkColorScale sub-schema](#slot-scaletype) | How the field's values map to colors, Vega-Lite's scale object. |
| **legend**<br>[MarkColorLegend sub-schema](#slot-legendvalues) | The key this channel's scale draws. |
| **legend.values**<br>[`stringArray`](https://jbrowse.org/jb2/docs/config_guides/slot_types#stringarray) = <code>[]</code> | The values an ordinal key lists, in this order; empty lists every value the loaded regions met. A value left out still paints, as Vega-Lite's `legend.values` and ggplot2's `breaks` leave it. |
| **legend.missingLabel**<br>[`maybeString`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | The key's name for a feature with nothing in `field`; unset is "(no value)". Vega-Lite's legend has no such member, so it keeps its JBrowse name. |
| **field**<br>[`featureField`](https://jbrowse.org/jb2/docs/config_guides/slot_types#featurefield) = <code>''</code> | the feature field a scale reads, or a jexl expression over feature, which is slower per feature |
| **scale.type**<br>[`maybeStringEnum`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) (ordinal, linear, log, symlog, threshold, identity) | ordinal assigns each distinct value a color from range; linear, log and symlog read the value between domainMin and domainMax into a ramp; threshold compares the value against the domain and gives each interval a range color; identity uses the CSS color its field holds, or with no field its own BED color, black included, the key naming the colors in domain; unset is linear for score and ordinal for any other field |
| **scale.domain**<br>[`stringArray`](https://jbrowse.org/jb2/docs/config_guides/slot_types#stringarray) = <code>[]</code> | for an ordinal scale, the values in legend order, walking the range from the first entry and continuing past its end into the scheme where one is set, else the default palette (a value left out takes a color no listed value or value met before it paints, the first time the track shows it, and keeps it); for a threshold scale, the cut points in ascending order, a value taking the range entry for the number of them it is at or past, so range has one entry more than this; a linear or log scale reads domainMin and domainMax instead |
| **scale.domainMin**<br>[`maybeNumber`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | the bottom of a ramp's domain; unset follows the loaded values |
| **scale.domainMax**<br>[`maybeNumber`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | the top of a ramp's domain; unset follows the loaded values |
| **scale.domainQuantile**<br>[`number`](https://jbrowse.org/jb2/docs/config_guides/slot_types#number) = <code>1</code> | the quantile an open end of a ramp follows over the loaded values: 1 their extremes, 0.99 clips the outermost 1% at each end, each sign measured on its own; a y scale fences at twice that span with fenceQuantile instead<br>_advanced_ |
| **scale.range**<br>[`colorArray`](https://jbrowse.org/jb2/docs/config_guides/slot_types#colorarray) = <code>[]</code> | CSS colors an ordinal scale hands its domain in order, a threshold scale its intervals, or a ramp's evenly spaced stops; empty, or short of the domain, takes the rest from the scheme where one is set, else the default palette for ordinal or the default ramp sampled per interval for threshold |
| **scale.unknown**<br>[`maybeColor`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | color for a value missing from domain. Unset: the next palette color where the display deals one, and the levels a preset field names, such as strand's, keep their own colors. A color: that color. "": no color dealt, so a feature paints the no-value grey, a variant cell the alt hue, and a row keeps the color it already has |
| **scale.invalid**<br>[`maybeColor`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | color for a feature with no value under an ordinal scale's field; unset, the display's no-value color |
| **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 |
| **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 |
| **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 |
| **legend.descending**<br>[`maybeBoolean`](https://jbrowse.org/jb2/docs/config_guides/slot_types#the-maybe-types) | threshold key lists the highest interval first; unset follows the field's preset, else the lowest first |

