value in fieldDef set the range value directly.
If users wanna provide domain value that needs to be scaled, we need to add another property.
From a conversation long time ago, we decided that this property is datum.
To clarify, a value property in VL produces a Vega ValueRef {value: value}.
Meanwhile, a datum property in VL should produces a Vega Value Ref {scale:..., value: datum} and use scale from relevant layers.
cc: @swojit
unit.tsWith this feature, the spec in https://github.com/vega/vega-lite/issues/3203#issuecomment-345422152 could become:
{
"data": {"url": "data/stocks.csv"},
"layer": [
{
"mark": "line",
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {"field": "price", "type": "quantitative"},
"color": {"field": "symbol", "type": "nominal"}
}
},
{
"mark": "rule",
"encoding": {
"y": { "datum": 100},
"size": {"value": 2}
}
}
]
}
Since this is just a syntactic sugar and there is already a good workaround, I don't think we will get to do it soon. Just in case any one wanna help, this would involve:
1) Add a new DatumDef as a new type of ChannelDef
2) Modify scale creation logic in parseUnitScaleCore in compile/scale/parse.ts to also create scales for datum.
3) Fix all the compile error due to new type of ChannelDef as DatumDef. This should include
compile/mark/valueref.ts and compile/mark/mixins.ts for how to apply datum with scale. (This part should be quite straightforward)4) The complicated part is deciding how we deal with axes and legends for datum.
Just want to add a voice of support for this feature. Yes, there is a work around, but it seems to me that this is a very common use case (at least it came up very quickly when some students in my lab started to use Vega-Lite) so it would be great if there was a smooth way to handle this, as this issue proposes. It seems like one of those things that really ought to be dead simple :)
Just trying to refresh my brain about this. Why did we decide to add a datum property rather than {scale: null} or {scale: identity}?
Never mind: https://github.com/vega/vega-lite/pull/3511#issuecomment-372148754.
Will be fixed in https://github.com/vega/vega-lite/pull/6150
Most helpful comment
Just want to add a voice of support for this feature. Yes, there is a work around, but it seems to me that this is a very common use case (at least it came up very quickly when some students in my lab started to use Vega-Lite) so it would be great if there was a smooth way to handle this, as this issue proposes. It seems like one of those things that really ought to be dead simple :)