today() 是否存在于 vega-lite 中?
Does today() exist in vega-lite?
我想显示数据中的日期 (Date1) 与图表中的“今天”之间的差异。我可以在我的 table 中添加一个包含今天日期的列,但我想知道我是否可以在 transform [] 语句中以某种方式解决这个问题以保持我的 table 精简。
做类似的事情:
today()
存在于 vega-lite 中?
您可以在 vega 表达式中使用 now()
函数;见 https://vega.github.io/vega/docs/expressions/#now
下面是添加带有今天日期 (open in editor) 的列的简单示例:
{
"data": {
"values": [
{"date": "2020-01-01T00:00:00"},
{"date": "2021-01-01T00:00:00"},
{"date": "2021-02-01T00:00:00"}
]
},
"transform": [{"calculate": "now()", "as": "today"}],
"mark": "point",
"encoding": {
"x": {"field": "today", "timeUnit": "yearmonthdate", "type": "ordinal"},
"y": {"field": "date", "timeUnit": "yearmonthdate", "type": "ordinal"}
}
}
我想显示数据中的日期 (Date1) 与图表中的“今天”之间的差异。我可以在我的 table 中添加一个包含今天日期的列,但我想知道我是否可以在 transform [] 语句中以某种方式解决这个问题以保持我的 table 精简。
做类似的事情:
today()
存在于 vega-lite 中?
您可以在 vega 表达式中使用 now()
函数;见 https://vega.github.io/vega/docs/expressions/#now
下面是添加带有今天日期 (open in editor) 的列的简单示例:
{
"data": {
"values": [
{"date": "2020-01-01T00:00:00"},
{"date": "2021-01-01T00:00:00"},
{"date": "2021-02-01T00:00:00"}
]
},
"transform": [{"calculate": "now()", "as": "today"}],
"mark": "point",
"encoding": {
"x": {"field": "today", "timeUnit": "yearmonthdate", "type": "ordinal"},
"y": {"field": "date", "timeUnit": "yearmonthdate", "type": "ordinal"}
}
}