altair.BarConfig

class altair.BarConfig(align=Undefined, angle=Undefined, aspect=Undefined, baseline=Undefined, binSpacing=Undefined, blend=Undefined, color=Undefined, continuousBandSize=Undefined, cornerRadius=Undefined, cornerRadiusBottomLeft=Undefined, cornerRadiusBottomRight=Undefined, cornerRadiusEnd=Undefined, cornerRadiusTopLeft=Undefined, cornerRadiusTopRight=Undefined, cursor=Undefined, dir=Undefined, discreteBandSize=Undefined, dx=Undefined, dy=Undefined, ellipsis=Undefined, fill=Undefined, fillOpacity=Undefined, filled=Undefined, font=Undefined, fontSize=Undefined, fontStyle=Undefined, fontWeight=Undefined, height=Undefined, href=Undefined, interpolate=Undefined, invalid=Undefined, limit=Undefined, lineBreak=Undefined, lineHeight=Undefined, opacity=Undefined, order=Undefined, orient=Undefined, radius=Undefined, shape=Undefined, size=Undefined, stroke=Undefined, strokeCap=Undefined, strokeDash=Undefined, strokeDashOffset=Undefined, strokeJoin=Undefined, strokeMiterLimit=Undefined, strokeOffset=Undefined, strokeOpacity=Undefined, strokeWidth=Undefined, tension=Undefined, text=Undefined, theta=Undefined, timeUnitBand=Undefined, timeUnitBandPosition=Undefined, tooltip=Undefined, width=Undefined, x=Undefined, x2=Undefined, y=Undefined, y2=Undefined, **kwds)

BarConfig schema wrapper

Mapping(required=[])

Attributes
alignAlign

The horizontal alignment of the text or ranged marks (area, bar, image, rect, rule). One of "left", "right", "center".

anglefloat

The rotation angle of the text, in degrees.

aspectboolean

Whether to keep aspect ratio of image marks.

baselineTextBaseline

The vertical text baseline. One of "alphabetic" (default), "top", "middle", "bottom", "line-top", or "line-bottom". The "line-top" and "line-bottom" values operate similarly to "top" and "bottom", but are calculated relative to the lineHeight rather than fontSize alone.

binSpacingfloat

Offset between bars for binned field. The ideal value for this is either 0 (preferred by statisticians) or 1 (Vega-Lite default, D3 example style).

Default value: 1

blendBlend

The color blend mode for drawing an item on its current background. Any valid CSS mix-blend-mode value can be used.

__Default value: "source-over"

coloranyOf(Color, Gradient)

Default color.

Default value: "#4682b4"

Note:

  • This property cannot be used in a style config.

  • The fill and stroke properties have higher precedence than color and will override color.

continuousBandSizefloat

The default size of the bars on continuous scales.

Default value: 5

cornerRadiusfloat

The radius in pixels of rounded rectangle corners.

Default value: 0

cornerRadiusBottomLeftfloat

The radius in pixels of rounded rectangle bottom left corner.

Default value: 0

cornerRadiusBottomRightfloat

The radius in pixels of rounded rectangle bottom right corner.

Default value: 0

cornerRadiusEndfloat
  • For vertical bars, top-left and top-right corner radius.

  • For horizontal bars, top-right and bottom-right corner radius.

cornerRadiusTopLeftfloat

The radius in pixels of rounded rectangle top right corner.

Default value: 0

cornerRadiusTopRightfloat

The radius in pixels of rounded rectangle top left corner.

Default value: 0

cursorCursor

The mouse cursor used over the mark. Any valid CSS cursor type can be used.

dirTextDirection

The direction of the text. One of "ltr" (left-to-right) or "rtl" (right-to-left). This property determines on which side is truncated in response to the limit parameter.

Default value: "ltr"

discreteBandSizefloat

The default size of the bars with discrete dimensions. If unspecified, the default size is step-2, which provides 2 pixel offset between bars.

dxfloat

The horizontal offset, in pixels, between the text label and its anchor point. The offset is applied after rotation by the angle property.

dyfloat

The vertical offset, in pixels, between the text label and its anchor point. The offset is applied after rotation by the angle property.

ellipsisstring

The ellipsis string for text truncated in response to the limit parameter.

Default value: "…"

fillanyOf(Color, Gradient, None)

Default Fill Color. This property has higher precedence than config.color.

Default value: (None)

fillOpacityfloat

The fill opacity (value between [0,1]).

Default value: 1

filledboolean

Whether the mark’s color should be used as fill color instead of stroke color.

Default value: false for all point, line, and rule marks as well as geoshape marks for graticule data sources; otherwise, true.

Note: This property cannot be used in a style config.

fontstring

The typeface to set the text in (e.g., "Helvetica Neue" ).

fontSizefloat

The font size, in pixels.

Default value: 11

fontStyleFontStyle

The font style (e.g., "italic" ).

fontWeightFontWeight

The font weight. This can be either a string (e.g "bold", "normal" ) or a number ( 100, 200, 300, …, 900 where "normal" = 400 and "bold" = 700 ).

heightfloat

Height of the marks.

hrefstring

A URL to load upon mouse click. If defined, the mark acts as a hyperlink.

interpolateInterpolate

The line interpolation method to use for line and area marks. One of the following:

  • "linear" : piecewise linear segments, as in a polyline.

  • "linear-closed" : close the linear segments to form a polygon.

  • "step" : alternate between horizontal and vertical segments, as in a step function.

  • "step-before" : alternate between vertical and horizontal segments, as in a step function.

  • "step-after" : alternate between horizontal and vertical segments, as in a step function.

  • "basis" : a B-spline, with control point duplication on the ends.

  • "basis-open" : an open B-spline; may not intersect the start or end.

  • "basis-closed" : a closed B-spline, as in a loop.

  • "cardinal" : a Cardinal spline, with control point duplication on the ends.

  • "cardinal-open" : an open Cardinal spline; may not intersect the start or end, but will intersect other control points.

  • "cardinal-closed" : a closed Cardinal spline, as in a loop.

  • "bundle" : equivalent to basis, except the tension parameter is used to straighten the spline.

  • "monotone" : cubic interpolation that preserves monotonicity in y.

invalidenum(‘filter’, None)

Defines how Vega-Lite should handle marks for invalid values ( null and NaN ).

  • If set to "filter" (default), all data items with null values will be skipped (for line, trail, and area marks) or filtered (for other marks).

  • If null, all data items are included. In this case, invalid values will be interpreted as zeroes.

limitfloat

The maximum length of the text mark in pixels. The text value will be automatically truncated if the rendered size exceeds the limit.

Default value: 0 – indicating no limit

lineBreakstring

A delimiter, such as a newline character, upon which to break text strings into multiple lines. This property is ignored if the text is array-valued.

lineHeightfloat

The line height in pixels (the spacing between subsequent lines of text) for multi-line text marks.

opacityfloat

The overall opacity (value between [0,1]).

Default value: 0.7 for non-aggregate plots with point, tick, circle, or square marks or layered bar charts and 1 otherwise.

orderanyOf(None, boolean)

For line and trail marks, this order property can be set to null or false to make the lines use the original order in the data sources.

orientOrientation

The orientation of a non-stacked bar, tick, area, and line charts. The value is either horizontal (default) or vertical.

  • For bar, rule and tick, this determines whether the size of the bar and tick

should be applied to x or y dimension. * For area, this property determines the orient property of the Vega output. * For line and trail marks, this property determines the sort order of the points in

the line

if config.sortLineBy is not specified. For stacked charts, this is always determined by the orientation of the stack; therefore explicitly specified value will be ignored.

radiusfloat

Polar coordinate radial offset, in pixels, of the text label from the origin determined by the x and y properties.

shapeanyOf(SymbolShape, string)

Shape of the point marks. Supported values include:

  • plotting shapes: "circle", "square", "cross", "diamond", "triangle-up", "triangle-down", "triangle-right", or "triangle-left".

  • the line symbol "stroke"

  • centered directional shapes "arrow", "wedge", or "triangle"

  • a custom SVG path string (For correct sizing, custom shape paths should be defined within a square bounding box with coordinates ranging from -1 to 1 along both the x and y dimensions.)

Default value: "circle"

sizefloat

Default size for marks.

  • For point / circle / square, this represents the pixel area of the marks. Note that this value sets the area of the symbol; the side lengths will increase with the square root of this value.

  • For bar, this represents the band size of the bar, in pixels.

  • For text, this represents the font size, in pixels.

Default value:

  • 30 for point, circle, square marks; width/height’s step

  • 2 for bar marks with discrete dimensions;

  • 5 for bar marks with continuous dimensions;

  • 11 for text marks.

strokeanyOf(Color, Gradient, None)

Default Stroke Color. This property has higher precedence than config.color.

Default value: (None)

strokeCapstring

The stroke cap for line ending style. One of "butt", "round", or "square".

Default value: "butt"

strokeDashList(float)

An array of alternating stroke, space lengths for creating dashed or dotted lines.

strokeDashOffsetfloat

The offset (in pixels) into which to begin drawing with the stroke dash array.

strokeJoinstring

The stroke line join method. One of "miter", "round" or "bevel".

Default value: "miter"

strokeMiterLimitfloat

The miter limit at which to bevel a line join.

strokeOffsetfloat

The offset in pixels at which to draw the group stroke and fill. If unspecified, the default behavior is to dynamically offset stroked groups such that 1 pixel stroke widths align with the pixel grid.

strokeOpacityfloat

The stroke opacity (value between [0,1]).

Default value: 1

strokeWidthfloat

The stroke width, in pixels.

tensionfloat

Depending on the interpolation type, sets the tension parameter (for line and area marks).

textText

Placeholder text if the text channel is not specified

thetafloat

Polar coordinate angle, in radians, of the text label from the origin determined by the x and y properties. Values for theta follow the same convention of arc mark startAngle and endAngle properties: angles are measured in radians, with 0 indicating “north”.

timeUnitBandfloat

Default relative band size for a time unit. If set to 1, the bandwidth of the marks will be equal to the time unit band step. If set to 0.5, bandwidth of the marks will be half of the time unit band step.

timeUnitBandPositionfloat

Default relative band position for a time unit. If set to 0, the marks will be positioned at the beginning of the time unit band step. If set to 0.5, the marks will be positioned in the middle of the time unit band step.

tooltipanyOf(float, string, boolean, TooltipContent, None)

The tooltip text string to show upon mouse hover or an object defining which fields should the tooltip be derived from.

  • If tooltip is true or {"content": "encoding"}, then all fields from encoding will be used.

  • If tooltip is {"content": "data"}, then all fields that appear in the highlighted data point will be used.

  • If set to null or false, then no tooltip will be used.

See the tooltip documentation for a detailed discussion about tooltip in Vega-Lite.

Default value: null

widthfloat

Width of the marks.

xanyOf(float, enum(‘width’))

X coordinates of the marks, or width of horizontal "bar" and "area" without specified x2 or width.

The value of this channel can be a number or a string "width" for the width of the plot.

x2anyOf(float, enum(‘width’))

X2 coordinates for ranged "area", "bar", "rect", and "rule".

The value of this channel can be a number or a string "width" for the width of the plot.

yanyOf(float, enum(‘height’))

Y coordinates of the marks, or height of vertical "bar" and "area" without specified y2 or height.

The value of this channel can be a number or a string "height" for the height of the plot.

y2anyOf(float, enum(‘height’))

Y2 coordinates for ranged "area", "bar", "rect", and "rule".

The value of this channel can be a number or a string "height" for the height of the plot.

__init__(self, align=Undefined, angle=Undefined, aspect=Undefined, baseline=Undefined, binSpacing=Undefined, blend=Undefined, color=Undefined, continuousBandSize=Undefined, cornerRadius=Undefined, cornerRadiusBottomLeft=Undefined, cornerRadiusBottomRight=Undefined, cornerRadiusEnd=Undefined, cornerRadiusTopLeft=Undefined, cornerRadiusTopRight=Undefined, cursor=Undefined, dir=Undefined, discreteBandSize=Undefined, dx=Undefined, dy=Undefined, ellipsis=Undefined, fill=Undefined, fillOpacity=Undefined, filled=Undefined, font=Undefined, fontSize=Undefined, fontStyle=Undefined, fontWeight=Undefined, height=Undefined, href=Undefined, interpolate=Undefined, invalid=Undefined, limit=Undefined, lineBreak=Undefined, lineHeight=Undefined, opacity=Undefined, order=Undefined, orient=Undefined, radius=Undefined, shape=Undefined, size=Undefined, stroke=Undefined, strokeCap=Undefined, strokeDash=Undefined, strokeDashOffset=Undefined, strokeJoin=Undefined, strokeMiterLimit=Undefined, strokeOffset=Undefined, strokeOpacity=Undefined, strokeWidth=Undefined, tension=Undefined, text=Undefined, theta=Undefined, timeUnitBand=Undefined, timeUnitBandPosition=Undefined, tooltip=Undefined, width=Undefined, x=Undefined, x2=Undefined, y=Undefined, y2=Undefined, **kwds)

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__(self[, align, angle, aspect, …])

Initialize self.

copy(self[, deep, ignore])

Return a copy of the object

from_dict(dct[, validate, _wrapper_classes])

Construct class from a dictionary representation

from_json(json_string[, validate])

Instantiate the object from a valid JSON string

resolve_references([schema])

Resolve references in the context of this object’s schema or root schema.

to_dict(self[, validate, ignore, context])

Return a dictionary representation of the object

to_json(self[, validate, ignore, context, …])

Emit the JSON representation for this object as a string.

validate(instance[, schema])

Validate the instance against the class schema in the context of the rootschema.

validate_property(name, value[, schema])

Validate a property against property schema in the context of the rootschema

copy(self, deep=True, ignore=())

Return a copy of the object

Parameters
deepboolean or list, optional

If True (default) then return a deep copy of all dict, list, and SchemaBase objects within the object structure. If False, then only copy the top object. If a list or iterable, then only copy the listed attributes.

ignorelist, optional

A list of keys for which the contents should not be copied, but only stored by reference.

classmethod from_dict(dct, validate=True, _wrapper_classes=None)

Construct class from a dictionary representation

Parameters
dctdictionary

The dict from which to construct the class

validateboolean

If True (default), then validate the input against the schema.

_wrapper_classeslist (optional)

The set of SchemaBase classes to use when constructing wrappers of the dict inputs. If not specified, the result of cls._default_wrapper_classes will be used.

Returns
objSchema object

The wrapped schema

Raises
jsonschema.ValidationError :

if validate=True and dct does not conform to the schema

classmethod from_json(json_string, validate=True, **kwargs)

Instantiate the object from a valid JSON string

Parameters
json_stringstring

The string containing a valid JSON chart specification.

validateboolean

If True (default), then validate the input against the schema.

**kwargs :

Additional keyword arguments are passed to json.loads

Returns
chartChart object

The altair Chart object built from the specification.

classmethod resolve_references(schema=None)

Resolve references in the context of this object’s schema or root schema.

to_dict(self, validate=True, ignore=None, context=None)

Return a dictionary representation of the object

Parameters
validateboolean or string

If True (default), then validate the output dictionary against the schema. If “deep” then recursively validate all objects in the spec. This takes much more time, but it results in friendlier tracebacks for large objects.

ignorelist

A list of keys to ignore. This will not passed to child to_dict function calls.

contextdict (optional)

A context dictionary that will be passed to all child to_dict function calls

Returns
dctdictionary

The dictionary representation of this object

Raises
jsonschema.ValidationError :

if validate=True and the dict does not conform to the schema

to_json(self, validate=True, ignore=[], context={}, indent=2, sort_keys=True, **kwargs)

Emit the JSON representation for this object as a string.

Parameters
validateboolean or string

If True (default), then validate the output dictionary against the schema. If “deep” then recursively validate all objects in the spec. This takes much more time, but it results in friendlier tracebacks for large objects.

ignorelist

A list of keys to ignore. This will not passed to child to_dict function calls.

contextdict (optional)

A context dictionary that will be passed to all child to_dict function calls

indentinteger, default 2

the number of spaces of indentation to use

sort_keysboolean, default True

if True, sort keys in the output

**kwargs

Additional keyword arguments are passed to json.dumps()

Returns
specstring

The JSON specification of the chart object.

classmethod validate(instance, schema=None)

Validate the instance against the class schema in the context of the rootschema.

classmethod validate_property(name, value, schema=None)

Validate a property against property schema in the context of the rootschema