属性中 "y2" 字段的 vega 堆积条语法
vega stacked bar syntax for "y2" field in properties
有人可以向我解释 vincent 文档中关于堆叠条的以下行吗:
https://github.com/wrobstory/vincent/blob/master/examples/stacked_bar_examples.py
y2=ValueRef(field='y2', scale='y')
我在数据集中没有看到任何名为 "y2" 的字段,所以我对它的来源感到困惑
y2
场由 Vega stack
变换 (code here) 生成。
在Vega中,rect
标记可以定义为y
+y2
或y
+height
。请参阅 Vega 文档中的 Marks#Shared Visual Properties:
For marks involving Cartesian extents (e.g., rect marks), the
horizontal dimensions are determined by (in order of precedence) the x
and x2 properties, the x and width properties, and the x2 and width
properties. If all three of x, x2 and width are specified, the width
value is ignored. The y, y2 and height properties are treated
similarly.
查看 stacked bar demo in the Vega Live Editor,其中包括:
...
"marks": [
{
"type": "rect",
"properties": {
"enter": {
"x": {"scale": "x", "field": "data.x"},
"width": {"scale": "x", "band": true, "offset": -1},
"y": {"scale": "y", "field": "y"},
"y2": {"scale": "y", "field": "y2"},
"fill": {"scale": "color", "field": "data.c"}
},
"update": {
"fillOpacity": {"value": 1}
},
"hover": {
"fillOpacity": {"value": 0.5}
}
}
}
]
...
尝试在实时编辑器中将 y2
更改为 height
。
有人可以向我解释 vincent 文档中关于堆叠条的以下行吗:
https://github.com/wrobstory/vincent/blob/master/examples/stacked_bar_examples.py
y2=ValueRef(field='y2', scale='y')
我在数据集中没有看到任何名为 "y2" 的字段,所以我对它的来源感到困惑
y2
场由 Vega stack
变换 (code here) 生成。
在Vega中,rect
标记可以定义为y
+y2
或y
+height
。请参阅 Vega 文档中的 Marks#Shared Visual Properties:
For marks involving Cartesian extents (e.g., rect marks), the horizontal dimensions are determined by (in order of precedence) the x and x2 properties, the x and width properties, and the x2 and width properties. If all three of x, x2 and width are specified, the width value is ignored. The y, y2 and height properties are treated similarly.
查看 stacked bar demo in the Vega Live Editor,其中包括:
...
"marks": [
{
"type": "rect",
"properties": {
"enter": {
"x": {"scale": "x", "field": "data.x"},
"width": {"scale": "x", "band": true, "offset": -1},
"y": {"scale": "y", "field": "y"},
"y2": {"scale": "y", "field": "y2"},
"fill": {"scale": "color", "field": "data.c"}
},
"update": {
"fillOpacity": {"value": 1}
},
"hover": {
"fillOpacity": {"value": 0.5}
}
}
}
]
...
尝试在实时编辑器中将 y2
更改为 height
。