This website is for Vega-Lite v4. Go to the main Vega-Lite homepage for the latest release.

Sample

Edit this page

The sample transform filters random rows from the data source to reduce its size. As input data objects are added and removed, the sampled values may change in first-in, first-out manner. This transform uses reservoir sampling to maintain a representative sample of the stream.

// Any View Specification
{
  ...
  "transform": [
    {"sample": ...} // Sample Transform
     ...
  ],
  ...
}

Sample Transform Definition

Property Type Description
sample Number

Required. The maximum number of data objects to include in the sample.

Default value: 1000

Usage

{"sample": 500}

Filters a data stream to a random sample of at most 500 data objects.

Example

Comparison between plots of the complete data and sampled data.