User Guide
Reference
Examples
Download
Github

vectors

The vectors statement adds an input data table, which is transformed according to a user-provided scale configuration and then plotted as one or more arrows to the chart. It is used to create vector field plots.

Synopsis

vectors { 
data: <dataset>;
data-format: <dataset-format>;
data-x: <dataset-x>;
data-y: <dataset-y>;
data-dx: <dataset-ref>;
data-dy: <dataset-ref>;
size: <size>;
sizes: <dataset_size>;
size-map: <measure_map>;
color: <color>;
colors: <dataset_colors>;
color-map: <color_map>;
scale-x: <scale>;
scale-y: <scale>;
limit-x: <limit>;
limit-x-min: <limit_min>;
limit-x-max: <limit-max>;
limit-y: <limit>;
limit-y-min: <limit_min>;
limit-y-max: <limit-max>;
}

List of Options

data

Set the dataset for the current element. The dataset should be a valid CSV (RFC4180) or GeoJSON file.

data: <path>;
Examples:
// load a csv file
data: "myfile.csv";

// load a geojson file
data: "myfile.geojson";

data-format

Explicitly set the dataset format. This is usually not required, since the format should, in most cases, be detected automatically.

data-format: <dataset-format>;
Examples:
// set the format to CSV
data-format: csv;

// set the format to geojson
data-format: geojson;

data-x

This parameter controls how the X position of geometry is retrieved from the dataset. For CSV files, the parameter controls the name of the column that is displayed on the X axis. The default value is `"x"`. You can also use this parameter to declare an "inline" data list.

data-x: <key>;
data-x: list(<value>...);
Examples:
// reference the "mycolumn" column
data-x: mycolumn;

// list of static values
data-x: list(10 20 30);

data-y

This parameter controls how the Y position of geometry is retrieved from the dataset. For CSV files, the parameter controls the name of the column that is displayed on the Y axis. The default value is `"y"`. You can also use this parameter to declare an "inline" data list.

data-y: <key>;
data-y: list(<value>...);
Examples:
// reference the "mycolumn" column
data-y: mycolumn;

// list of static values
data-y: list(10 20 30);

data-dx

Set the 'dx' dataset for the plot. The 'x' dataset will be used to calculate the horizontal size of arrows.

data-dx: <key>;
data-dx: list(<values>...);
Examples:
;; reference the "mycolumn" column (CSV)
data-dx: mycolumn;

;; list of static values
data-dx: list(10 20 30);

data-dy

Set the 'dy' dataset for the plot. The 'y' dataset will be used to calculate the vertical size of arrows.

data-dy: <key>;
data-dy: list(<values>...);
Examples:
;; reference the "mycolumn" column (CSV)
data-dy: mycolumn;

;; list of static values
data-dy: list(10 20 30);

size

Set the vector size.

size: <measure>;
Examples:
;; set size to 2pt
size: 2pt;

sizes

Set an individual size for each vector

size-map

Controls how input data in sizes is mapped to typographic units.

color

Set the vector color. Note that this value is only used if no colors option is specified.

color: <color>;
Examples:
;; set the color to grey
color: #eee;

;; set the color to red, 50% transparent
color: rgba(1 0 0 .5);

colors

Set an individual color for each vector. If no explicit color-map option is provided, the values in colors will be interpreted as hex color codes. Otherwise the mapping of input data to colors is controlled by the color-map option.

color-map

Controls how input data is mapped to colors. If no map is specified, the values in colors will be interpreted as hex color values.

scale-x

Set the type of the 'x' (horizontal) scale.

scale-x: [linear] [log] [logarithmic] [invert] [inverted];

List of scale types: - `linear` - Standard linear scale - `log`, `logarithmic` - Logarithmic (log10) scale - `invert`, `inverted` - Flip the scale

Examples:
;; set the scale to logarithmic mode
scale-x: log;

;; set the scale to inverted mode
scale-x: invert;

scale-y

Set the type of the 'y' (vertical) scale.

scale-y: [linear] [log] [logarithmic] [invert] [inverted];

List of scale types: - `linear` - Standard linear scale - `log`, `logarithmic` - Logarithmic (log10) scale - `invert`, `inverted` - Flip the scale

Examples:
;; set the scale to logarithmic mode
scale-y: log;

;; set the scale to inverted mode
scale-y: invert;

limit-x

Set the limits (minimum and maximum values) for the 'x' (horizontal) scale.

limit-x: <min> <max;
Examples:
;; set limits to [1..10]
limit-x: 1 10;

limit-x-min

Set the minimum value (lower limit) for the 'x' (horizontal) scale.

limit-x-min: <min>;
Examples:
;; set the lower limit to 2
limit-x-min: 2;

limit-x-max

Set the maximum value (upper limit) for the 'x' (horizontal) scale.

limit-x-max: <value>;
Examples:
;; set the upper limit to 20
limit-x-max: 20;

limit-y

Set the limits (minimum and maximum values) for the 'y' (vertical) scale.

limit-y: <min> <max;
Examples:
;; set limits to [1..10]
limit-y: 1 10;

limit-y-min

Set the minimum value (lower limit) for the 'y' (vertical) scale.

limit-y-min: <min>;
Examples:
;; set the lower limit to 2
limit-y-min: 2;

limit-y-max

Set the maximum value (upper limit) for the 'y' (vertical) scale.

limit-y-max: <value>;
Examples:
;; set the upper limit to 20
limit-y-max: 20;

Examples

Example: examples/charts-scientific/vectorfield


Edit this page on GitHub