具有预装箱数据的网格
Grid with Pre-Binned Data
通过 "bin": "binned"
我可以使用预分箱数据。如何启用网格?似乎在 vega-lite 到 vega 的转换过程中,我的 grid
设置被覆盖为 false
.
{ "mark": "bar",
"encoding": {
"x": {
"type": "temporal",
"bin": "binned",
"field": "start",
"axis": {"grid": true}
},
"x2": {"field": "end"},
"y": {"type": "quantitative", "field": "value"}
},
"transform": [
{"calculate": "toDate(datum.day)", "as": "day"},
{"calculate": "timeOffset('hours', datum.day, -12)", "as": "start"},
{"calculate": "timeOffset('hours', datum.day, 12)", "as": "end"}
],
"height": 250,
"width": 800,
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"values": [
{"day": "2021-01-01T00:00:00", "value": 5},
{"day": "2021-01-02T00:00:00", "value": 4},
{"day": "2021-01-04T00:00:00", "value": 5},
{"day": "2021-01-05T00:00:00", "value": 4},
{"day": "2021-01-09T00:00:00", "value": 1},
{"day": "2021-01-10T00:00:00", "value": 3},
{"day": "2021-01-11T00:00:00", "value": 2},
{"day": "2021-01-12T00:00:00", "value": 3},
{"day": "2021-01-13T00:00:00", "value": 5},
{"day": "2021-01-15T00:00:00", "value": 3}
]
}}
如果没有模式解决方案,是否可以通过view
api重新启用网格?
好吧,这太可怕了。使用匹配的编码分层垃圾图,所有标记都是透明的。希望有人有更好的解决方案。
{ "layer": [
{
"mark": "bar",
"encoding": {
"x": {
"type": "temporal",
"bin": "binned",
"field": "start",
"axis": {"grid": true},
"title": "day"
},
"x2": {"field": "end"},
"y": {"type": "quantitative", "field": "value"}
}
},
{
"mark": {"type": "point", "opacity": 0},
"encoding": {
"x": {
"type": "temporal",
"field": "start",
"axis": {"grid": true}
},
"y": {
"field": "value",
"axis": {"grid": true},
"type": "quantitative"}
}
}
],
"transform": [
{"calculate": "toDate(datum.day)", "as": "day"},
{"calculate": "timeOffset('hours', datum.day, -12)", "as": "start"},
{"calculate": "timeOffset('hours', datum.day, 12)", "as": "end"}
],
"height": 250,
"width": 800,
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"values": [
{"day": "2021-01-01T00:00:00", "value": 5},
{"day": "2021-01-02T00:00:00", "value": 4},
{"day": "2021-01-04T00:00:00", "value": 5},
{"day": "2021-01-05T00:00:00", "value": 4},
{"day": "2021-01-09T00:00:00", "value": 1},
{"day": "2021-01-10T00:00:00", "value": 3},
{"day": "2021-01-11T00:00:00", "value": 2},
{"day": "2021-01-12T00:00:00", "value": 3},
{"day": "2021-01-13T00:00:00", "value": 5},
{"day": "2021-01-15T00:00:00", "value": 3}
]
}
}
这是解决此问题的拉取请求。可能不会导致任何结果。
- #7192 修复:在 ("bin":"binned")
时允许轴设置
通过 "bin": "binned"
我可以使用预分箱数据。如何启用网格?似乎在 vega-lite 到 vega 的转换过程中,我的 grid
设置被覆盖为 false
.
{ "mark": "bar",
"encoding": {
"x": {
"type": "temporal",
"bin": "binned",
"field": "start",
"axis": {"grid": true}
},
"x2": {"field": "end"},
"y": {"type": "quantitative", "field": "value"}
},
"transform": [
{"calculate": "toDate(datum.day)", "as": "day"},
{"calculate": "timeOffset('hours', datum.day, -12)", "as": "start"},
{"calculate": "timeOffset('hours', datum.day, 12)", "as": "end"}
],
"height": 250,
"width": 800,
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"values": [
{"day": "2021-01-01T00:00:00", "value": 5},
{"day": "2021-01-02T00:00:00", "value": 4},
{"day": "2021-01-04T00:00:00", "value": 5},
{"day": "2021-01-05T00:00:00", "value": 4},
{"day": "2021-01-09T00:00:00", "value": 1},
{"day": "2021-01-10T00:00:00", "value": 3},
{"day": "2021-01-11T00:00:00", "value": 2},
{"day": "2021-01-12T00:00:00", "value": 3},
{"day": "2021-01-13T00:00:00", "value": 5},
{"day": "2021-01-15T00:00:00", "value": 3}
]
}}
如果没有模式解决方案,是否可以通过view
api重新启用网格?
好吧,这太可怕了。使用匹配的编码分层垃圾图,所有标记都是透明的。希望有人有更好的解决方案。
{ "layer": [
{
"mark": "bar",
"encoding": {
"x": {
"type": "temporal",
"bin": "binned",
"field": "start",
"axis": {"grid": true},
"title": "day"
},
"x2": {"field": "end"},
"y": {"type": "quantitative", "field": "value"}
}
},
{
"mark": {"type": "point", "opacity": 0},
"encoding": {
"x": {
"type": "temporal",
"field": "start",
"axis": {"grid": true}
},
"y": {
"field": "value",
"axis": {"grid": true},
"type": "quantitative"}
}
}
],
"transform": [
{"calculate": "toDate(datum.day)", "as": "day"},
{"calculate": "timeOffset('hours', datum.day, -12)", "as": "start"},
{"calculate": "timeOffset('hours', datum.day, 12)", "as": "end"}
],
"height": 250,
"width": 800,
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {
"values": [
{"day": "2021-01-01T00:00:00", "value": 5},
{"day": "2021-01-02T00:00:00", "value": 4},
{"day": "2021-01-04T00:00:00", "value": 5},
{"day": "2021-01-05T00:00:00", "value": 4},
{"day": "2021-01-09T00:00:00", "value": 1},
{"day": "2021-01-10T00:00:00", "value": 3},
{"day": "2021-01-11T00:00:00", "value": 2},
{"day": "2021-01-12T00:00:00", "value": 3},
{"day": "2021-01-13T00:00:00", "value": 5},
{"day": "2021-01-15T00:00:00", "value": 3}
]
}
}
这是解决此问题的拉取请求。可能不会导致任何结果。
- #7192 修复:在 ("bin":"binned") 时允许轴设置