altair.Header#

class altair.Header(format=Undefined, formatType=Undefined, labelAlign=Undefined, labelAnchor=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOrient=Undefined, labelPadding=Undefined, labels=Undefined, orient=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOrient=Undefined, titlePadding=Undefined, **kwds)#

Header Schema 包装器。

用于分面图表的行/列通道的标头。

参数:
formatstr, dict, Dict

当与默认的 "number" 和 "time" 格式类型一起使用时,这是 guides (轴、图例、标头) 标签和文本标记的文本格式模式。

  • 如果格式类型是 "number" (例如,用于定量字段),这是 D3 的 数字格式模式

  • 如果格式类型是 "time" (例如,用于时间字段),这是 D3 的 时间格式模式

更多示例请参阅格式文档

当与自定义格式类型一起使用时,此值将作为 formatdatum.value 一起传递给注册的函数。

默认值:对于数字格式,派生自 numberFormat 配置;对于时间格式,派生自 timeFormat 配置。

formatTypestr

标签的格式类型。可以是 "number""time"注册的自定义格式类型之一。

默认值

  • 对于时间字段以及带有 timeUnit 的有序和名义字段,为 "time"

  • 对于定量字段以及不带 timeUnit 的有序和名义字段,为 "number"

labelAligndict, Align, ExprRef, Literal[‘left’, ‘center’, ‘right’]

标头标签的水平文本对齐方式。可以是 "left""center""right" 之一。

labelAnchorTitleAnchor, Literal[None, ‘start’, ‘middle’, ‘end’]

放置标签的锚点位置。可以是 "start""middle""end" 之一。例如,当标签方向为顶部时,这些锚点位置分别对应左对齐、居中对齐或右对齐的标签。

labelAnglefloat

标头标签的旋转角度。

默认值:列标头为 0,行标头为 -90

labelBaselinedict, ExprRef, Baseline, TextBaseline, Literal[‘alphabetic’, ‘line-bottom’, ‘line-top’, ‘top’, ‘middle’, ‘bottom’]

标头标签的垂直文本基线。可以是 "alphabetic"(默认)、"top""middle""bottom""line-top""line-bottom" 之一。"line-top""line-bottom" 的作用类似于 "top""bottom",但它们的计算是相对于 titleLineHeight 而非仅相对于 titleFontSize

labelColorstr, dict, Color, ExprRef, HexColor, ColorName, Literal[‘black’, ‘silver’, ‘gray’, ‘white’, ‘maroon’, ‘red’, ‘purple’, ‘fuchsia’, ‘green’, ‘lime’, ‘olive’, ‘yellow’, ‘navy’, ‘blue’, ‘teal’, ‘aqua’, ‘orange’, ‘aliceblue’, ‘antiquewhite’, ‘aquamarine’, ‘azure’, ‘beige’, ‘bisque’, ‘blanchedalmond’, ‘blueviolet’, ‘brown’, ‘burlywood’, ‘cadetblue’, ‘chartreuse’, ‘chocolate’, ‘coral’, ‘cornflowerblue’, ‘cornsilk’, ‘crimson’, ‘cyan’, ‘darkblue’, ‘darkcyan’, ‘darkgoldenrod’, ‘darkgray’, ‘darkgreen’, ‘darkgrey’, ‘darkkhaki’, ‘darkmagenta’, ‘darkolivegreen’, ‘darkorange’, ‘darkorchid’, ‘darkred’, ‘darksalmon’, ‘darkseagreen’, ‘darkslateblue’, ‘darkslategray’, ‘darkslategrey’, ‘darkturquoise’, ‘darkviolet’, ‘deeppink’, ‘deepskyblue’, ‘dimgray’, ‘dimgrey’, ‘dodgerblue’, ‘firebrick’, ‘floralwhite’, ‘forestgreen’, ‘gainsboro’, ‘ghostwhite’, ‘gold’, ‘goldenrod’, ‘greenyellow’, ‘grey’, ‘honeydew’, ‘hotpink’, ‘indianred’, ‘indigo’, ‘ivory’, ‘khaki’, ‘lavender’, ‘lavenderblush’, ‘lawngreen’, ‘lemonchiffon’, ‘lightblue’, ‘lightcoral’, ‘lightcyan’, ‘lightgoldenrodyellow’, ‘lightgray’, ‘lightgreen’, ‘lightgrey’, ‘lightpink’, ‘lightsalmon’, ‘lightseagreen’, ‘lightskyblue’, ‘lightslategray’, ‘lightslategrey’, ‘lightsteelblue’, ‘lightyellow’, ‘limegreen’, ‘linen’, ‘magenta’, ‘mediumaquamarine’, ‘mediumblue’, ‘mediumorchid’, ‘mediumpurple’, ‘mediumseagreen’, ‘mediumslateblue’, ‘mediumspringgreen’, ‘mediumturquoise’, ‘mediumvioletred’, ‘midnightblue’, ‘mintcream’, ‘mistyrose’, ‘moccasin’, ‘navajowhite’, ‘oldlace’, ‘olivedrab’, ‘orangered’, ‘orchid’, ‘palegoldenrod’, ‘palegreen’, ‘paleturquoise’, ‘palevioletred’, ‘papayawhip’, ‘peachpuff’, ‘peru’, ‘pink’, ‘plum’, ‘powderblue’, ‘rosybrown’, ‘royalblue’, ‘saddlebrown’, ‘salmon’, ‘sandybrown’, ‘seagreen’, ‘seashell’, ‘sienna’, ‘skyblue’, ‘slateblue’, ‘slategray’, ‘slategrey’, ‘snow’, ‘springgreen’, ‘steelblue’, ‘tan’, ‘thistle’, ‘tomato’, ‘turquoise’, ‘violet’, ‘wheat’, ‘whitesmoke’, ‘yellowgreen’, ‘rebeccapurple’]

标头标签的颜色,可以是十六进制颜色代码或常规颜色名称。

labelExprstr

用于自定义标签的Vega 表达式

注意:可以通过标头后备 datum 对象的 labelvalue 属性来访问标签文本和值。

labelFontstr, dict, ExprRef

标头标签的字体。

labelFontSizedict, float, ExprRef

标头标签的字体大小,单位为像素。

labelFontStylestr, dict, ExprRef, FontStyle

标头标签的字体样式。

labelFontWeightdict, ExprRef, FontWeight, Literal[‘normal’, ‘bold’, ‘lighter’, ‘bolder’, 100, 200, 300, 400, 500, 600, 700, 800, 900]

标头标签的字体粗细。

labelLimitdict, float, ExprRef

标头标签的最大长度,单位为像素。如果渲染尺寸超出限制,文本值将自动截断。

默认值:0,表示无限制。

labelLineHeightdict, float, ExprRef

多行标头标签或使用 "line-top""line-bottom" 基线的标题文本的行高,单位为像素。

labelOrientOrient, Literal[‘left’, ‘right’, ‘top’, ‘bottom’]

标头标签的方向。可以是 "top""bottom""left""right" 之一。

labelPaddingdict, float, ExprRef

分面标头的标签与图表之间的填充(间距),单位为像素。

默认值:10

labelsbool

一个布尔标志,指示标签是否应作为标头的一部分包含。

默认值:true

orientOrient, Literal[‘left’, ‘right’, ‘top’, ‘bottom’]

同时设置 labelOrienttitleOrient 的快捷方式。

titlestr, Text, Sequence[str], None

字段的标题。如果为 null,则将移除标题。

默认值:从字段名称和转换函数(aggregatebintimeUnit)派生。如果字段具有聚合函数,函数将作为标题的一部分显示(例如,“Profit 的总和”)。如果字段被分箱或应用了时间单位,应用的函数将显示在括号中(例如,“Profit (binned)”,“交易日期 (年-月)”)。否则,标题就是字段名称。

注意:

1) 您可以通过在配置中提供 fieldTitle 属性,或通过 compile 函数的选项提供 fieldTitle 函数来自定义默认字段标题格式。

2) 如果字段定义的 title 和轴、标头或图例的 title 都已定义,则将使用轴/标头/图例的标题。

titleAligndict, Align, ExprRef, Literal[‘left’, ‘center’, ‘right’]

标头标题的水平文本对齐方式(相对于锚点)。

titleAnchorTitleAnchor, Literal[None, ‘start’, ‘middle’, ‘end’]

放置标题的锚点位置。可以是 "start""middle""end" 之一。例如,当方向为顶部时,这些锚点位置分别对应左对齐、居中对齐或右对齐的标题。

titleAnglefloat

标头标题的旋转角度。

默认值:0

titleBaselinedict, ExprRef, Baseline, TextBaseline, Literal[‘alphabetic’, ‘line-bottom’, ‘line-top’, ‘top’, ‘middle’, ‘bottom’]

标头标题的垂直文本基线。可以是 "alphabetic"(默认)、"top""middle""bottom""line-top""line-bottom" 之一。"line-top""line-bottom" 的作用类似于 "top""bottom",但它们的计算是相对于 titleLineHeight 而非仅相对于 titleFontSize

默认值:"middle"

titleColorstr, dict, Color, ExprRef, HexColor, ColorName, Literal[‘black’, ‘silver’, ‘gray’, ‘white’, ‘maroon’, ‘red’, ‘purple’, ‘fuchsia’, ‘green’, ‘lime’, ‘olive’, ‘yellow’, ‘navy’, ‘blue’, ‘teal’, ‘aqua’, ‘orange’, ‘aliceblue’, ‘antiquewhite’, ‘aquamarine’, ‘azure’, ‘beige’, ‘bisque’, ‘blanchedalmond’, ‘blueviolet’, ‘brown’, ‘burlywood’, ‘cadetblue’, ‘chartreuse’, ‘chocolate’, ‘coral’, ‘cornflowerblue’, ‘cornsilk’, ‘crimson’, ‘cyan’, ‘darkblue’, ‘darkcyan’, ‘darkgoldenrod’, ‘darkgray’, ‘darkgreen’, ‘darkgrey’, ‘darkkhaki’, ‘darkmagenta’, ‘darkolivegreen’, ‘darkorange’, ‘darkorchid’, ‘darkred’, ‘darksalmon’, ‘darkseagreen’, ‘darkslateblue’, ‘darkslategray’, ‘darkslategrey’, ‘darkturquoise’, ‘darkviolet’, ‘deeppink’, ‘deepskyblue’, ‘dimgray’, ‘dimgrey’, ‘dodgerblue’, ‘firebrick’, ‘floralwhite’, ‘forestgreen’, ‘gainsboro’, ‘ghostwhite’, ‘gold’, ‘goldenrod’, ‘greenyellow’, ‘grey’, ‘honeydew’, ‘hotpink’, ‘indianred’, ‘indigo’, ‘ivory’, ‘khaki’, ‘lavender’, ‘lavenderblush’, ‘lawngreen’, ‘lemonchiffon’, ‘lightblue’, ‘lightcoral’, ‘lightcyan’, ‘lightgoldenrodyellow’, ‘lightgray’, ‘lightgreen’, ‘lightgrey’, ‘lightpink’, ‘lightsalmon’, ‘lightseagreen’, ‘lightskyblue’, ‘lightslategray’, ‘lightslategrey’, ‘lightsteelblue’, ‘lightyellow’, ‘limegreen’, ‘linen’, ‘magenta’, ‘mediumaquamarine’, ‘mediumblue’, ‘mediumorchid’, ‘mediumpurple’, ‘mediumseagreen’, ‘mediumslateblue’, ‘mediumspringgreen’, ‘mediumturquoise’, ‘mediumvioletred’, ‘midnightblue’, ‘mintcream’, ‘mistyrose’, ‘moccasin’, ‘navajowhite’, ‘oldlace’, ‘olivedrab’, ‘orangered’, ‘orchid’, ‘palegoldenrod’, ‘palegreen’, ‘paleturquoise’, ‘palevioletred’, ‘papayawhip’, ‘peachpuff’, ‘peru’, ‘pink’, ‘plum’, ‘powderblue’, ‘rosybrown’, ‘royalblue’, ‘saddlebrown’, ‘salmon’, ‘sandybrown’, ‘seagreen’, ‘seashell’, ‘sienna’, ‘skyblue’, ‘slateblue’, ‘slategray’, ‘slategrey’, ‘snow’, ‘springgreen’, ‘steelblue’, ‘tan’, ‘thistle’, ‘tomato’, ‘turquoise’, ‘violet’, ‘wheat’, ‘whitesmoke’, ‘yellowgreen’, ‘rebeccapurple’]

标头标题的颜色,可以是十六进制颜色代码或常规颜色名称。

titleFontstr, dict, ExprRef

标头标题的字体。(例如,"Helvetica Neue")。

titleFontSizedict, float, ExprRef

标头标题的字体大小。

titleFontStylestr, dict, ExprRef, FontStyle

标头标题的字体样式。

titleFontWeightdict, ExprRef, FontWeight, Literal[‘normal’, ‘bold’, ‘lighter’, ‘bolder’, 100, 200, 300, 400, 500, 600, 700, 800, 900]

标头标题的字体粗细。可以是字符串(例如 "bold""normal")或数字(100200300、…、900,其中 "normal" = 400"bold" = 700)。

titleLimitdict, float, ExprRef

标头标题的最大长度,单位为像素。如果渲染尺寸超出限制,文本值将自动截断。

默认值:0,表示无限制。

titleLineHeightdict, float, ExprRef

多行标头标题文本或使用 "line-top""line-bottom" 基线的标题文本的行高,单位为像素。

titleOrientOrient, Literal[‘left’, ‘right’, ‘top’, ‘bottom’]

标头标题的方向。可以是 "top""bottom""left""right" 之一。

titlePaddingdict, float, ExprRef

分面标头的标题与标签之间的填充(间距),单位为像素。

默认值:10

__init__(format=Undefined, formatType=Undefined, labelAlign=Undefined, labelAnchor=Undefined, labelAngle=Undefined, labelBaseline=Undefined, labelColor=Undefined, labelExpr=Undefined, labelFont=Undefined, labelFontSize=Undefined, labelFontStyle=Undefined, labelFontWeight=Undefined, labelLimit=Undefined, labelLineHeight=Undefined, labelOrient=Undefined, labelPadding=Undefined, labels=Undefined, orient=Undefined, title=Undefined, titleAlign=Undefined, titleAnchor=Undefined, titleAngle=Undefined, titleBaseline=Undefined, titleColor=Undefined, titleFont=Undefined, titleFontSize=Undefined, titleFontStyle=Undefined, titleFontWeight=Undefined, titleLimit=Undefined, titleLineHeight=Undefined, titleOrient=Undefined, titlePadding=Undefined, **kwds)#

方法

__init__([format, formatType, labelAlign, ...])

copy([deep, ignore])

返回对象的副本。

from_dict(dct[, validate])

从字典表示构造类。

from_json(json_string[, validate])

从有效的 JSON 字符串实例化对象。

resolve_references([schema])

在此对象 schema 或根 schema 的上下文中解析引用。

to_dict([validate, ignore, context])

返回对象的字典表示。

to_json([validate, indent, sort_keys, ...])

将此对象的 JSON 表示输出为字符串。

validate(instance[, schema])

在根 schema 的上下文中根据类 schema 验证实例。

validate_property(name, value[, schema])

在根 schema 的上下文中根据属性 schema 验证属性。