Skip to content

Commit

Permalink
[WIP] docs: size
Browse files Browse the repository at this point in the history
  • Loading branch information
kanitw committed Jun 29, 2019
1 parent 0215145 commit 494fcfe
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions site/docs/view/size.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,17 @@ When the top-level `width` property is specified, the width of the single plot i

<span class="vl-example" data-name="bar_size_explicit"></span>

**Note**: If numeric `rangeStep` for a discrete x/y-scale is specified when `width` / `height` is specified, the `rangeStep` will be ignored (overridden with `null`).

**Warning**: If the cardinality of the x/y-field's domain is too high, the `rangeStep` might become less than one pixel and the mark might not appear correctly.

<span class="vl-example" data-name="bar_size_explicit_bad"></span>

### Default Width and Height

If the top-level `width` / `height` property is not specified, the width / height of a single view is determined by the properties of the `x` / `y` channel:

- If (1) the view's [`autosize`](#autosize) type is `"fit"` or (2) the `x` / `y` axis has a continuous scale (either quantitative or time) or a discrete scale with `rangeStep` = `null`, the width/height is drawn directly from the [`config.view.width`](spec.html#config) / [`config.view.height`](spec.html#config) property.

- If the [`autosize`](#autosize) type is not `"fit"` and the `x` / `y` channel has a [band or point scale](scale.html#band) in which `rangeStep` is a number or unspecified, the width / height is [determined based on the scale's range step, paddings, and the cardinality of the encoded field (the number of possible distinct values of the field)](scale.html#band).
<span class="vl-example" data-name="bar_size_fit"></span>

This example shows a plot with a continuous y-scale and a discrete x-scale:
### Default Width and Height

<span class="vl-example" data-name="bar_size_default"></span>
If the top-level `width` / `height` property is not specified, the width / height of a single view is determined based on the view config.

- If the `x` / `y` channel has a discrete scale with `rangeStep` = `null`, the width / height is drawn directly from the [`config.view.width`](spec.html#config) / [`config.view.height`](spec.html#config) property and the band of the scale will be adjusted to fit to the width.
- The width will be based on `config.view.continuousWidth` for a plot with a continuous x-field and, otherwise, `config.view.discreteWidth`.

<span class="vl-example" data-name="bar_size_fit"></span>

- If `x` / `y` is not mapped to a field, the width / height is derived from [config.scale.rangeStep](#scale-config).
- The height will be based on `config.view.continuousHeight` for a plot with a continuous y-field and, otherwise, `config.view.discreteHeight`.

For example, the following plot use `21` as a default height.

Expand All @@ -69,10 +57,7 @@ The total size of a Vega-Lite visualization may be determined by multiple factor

#### Limitations

In order to `fit` a chart into specified dimensions, it has to satisfy two requirements:

- The view must be either a [single](spec.html#single) view or a [layered](layer.html) view. Fit does not work with other kinds of composed views (`facet`/`hconcat`/`vconcat`/`repeat`).
- The width and height of the chart cannot depend on an explicitly specified `rangeStep` of a discrete scale. Any specified `rangeStep` will be ignored.
In order to `fit` a chart into specified dimensions, the view must be either a [single](spec.html#single) view or a [layered](layer.html) view. Fit does not work with other kinds of composed views (`facet`/`hconcat`/`vconcat`/`repeat`).

#### Example

Expand Down

0 comments on commit 494fcfe

Please sign in to comment.