vega/vega-parser

Name: vega-parser

Owner: Vega

Description: Parse Vega specifications to runtime dataflows.

Created: 2016-06-10 23:26:29.0

Updated: 2018-01-13 14:00:42.0

Pushed: 2018-01-18 05:11:39.0

Homepage:

Size: 445

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

vega-parser

Parse Vega specifications to runtime dataflow descriptions.

API Reference

# vega.parse(specification[, config]) <>

Parses a Vega JSON specification as input and produces a reactive dataflow graph description for a visualization. The output description uses the format of the vega-runtime module. To create a visualization, use the runtime dataflow description as the input to a Vega View instance.

The optional config object provides visual encoding defaults for marks, scales, axes and legends. Different configuration settings can be used to change choices of layout, color, type faces, font sizes and more to realize different chart themes. For more, see the configuration documentation below or view the source code defining Vega's default configuration.

In addition to passing configuration options to this parse method, Vega JSON specifications may also include a top-level "config" block specifying configuration properties. Configuration options defined within a Vega JSON file take precedence over those provided to the parse method.

Configuration Reference

The Vega parser accepts a configuration file that defines default settings for a variety of visual encoding choices. Different configuration files can be used to “theme” charts with a customized look and feel. A configuration file is simply a JavaScript object with a set of named properties, grouped by type.

Top-Level Properties

Properties defined in the top-level scope of the configuration object.

Event Properties

Properties for event handling configuration, defined within an "events" property block.

For example, to prevent the default behavior for all events originating within a Vega view except for wheel events:

nts": {
efaults": {
"allow": ["wheel"]


Mark Properties

Properties defining default attributes for visualized marks. These properties are defined within blocks with names matching a valid mark type (e.g., "area", "line", "rect"). The valid properties within each block consist of the legal mark properties (e.g., "fill", "stroke", "size", "font").

For example, to set default fill color and size for symbol marks:

bol": {
ill": "steelblue",
ize": 64

Defaults for fill or stroke color will only be applied if neither the "fill" not "stroke" properties are defined.

In addition, global defaults for all mark types can be set using the "mark" config property. For example, to set a global opacity value:

k": {
pacity": 0.8

Style Properties

In addition to the default mark properties above, default values can be further customized using named styles defined under the style block in the config. Styles can then be invoked by including a style directive within a mark definition.

For example, to set a default shape and stroke width for symbol marks with a style named "square":

le": {
quare": {
"shape": "square",
"strokeWidth": 2


Style settings take precedence over default mark settings, but are overridden by the axis, legend, and title properties described below.

Axis Properties

Properties defining default settings for axes. These properties are defined within an "axis" property block, which applies to all axes. Additional property blocks can target more specific axis types based on the orientation ("axisX", "axisY", "axisLeft", "axisTop", etc.) or band scale type ("axisBand"). For example, properties defined under the "axisBand" block will only apply to axes visualizing "band" scales. If multiple axis config blocks apply to a single axis, type-based options take precedence over orientation-based options, which in turn take precedence over general options.

Legend Properties

Properties defining default settings for legends. These properties are defined within a "legend" property block.

Title Properties

Properties defining default settings for titles. These properties are defined within a "title" property block.

Scale Range Properties

Properties defining named range arrays that can be used within scale range definitions (such as {"type": "ordinal", "range": "category"}). These properties are defined within a "range" block.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.