-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Description
Bug Description
Example: if the data range from 19 to 91, but the domainMid is -20, it's producing a funny scale
{
"$schema": "https://vega.github.io/schema/vega-lite/v6.json",
"description": "A simple bar chart with embedded data.",
"data": {
"values": [
{"a": "A", "b": 28}, {"a": "B", "b": 55}, {"a": "C", "b": 43},
{"a": "D", "b": 91}, {"a": "E", "b": 81}, {"a": "F", "b": 53},
{"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52}
]
},
"mark": "bar",
"encoding": {
"x": {"field": "a", "type": "nominal", "axis": {"labelAngle": 0}},
"y": {"field": "b", "type": "quantitative"},
"color": {
"field": "b", "type": "quantitative",
"scale": {"type": "linear", "scheme": "redblue", "domainMid": -20}
}
}
}
Expected:
the mid should be mapped to the middle of the ramp
Note that we if I add another layer with datum = -20
{
"$schema": "https://vega.github.io/schema/vega-lite/v6.json",
"description": "A simple bar chart with embedded data.",
"data": {
"values": [
{"a": "A", "b": 28}, {"a": "B", "b": 55}, {"a": "C", "b": 43},
{"a": "D", "b": 91}, {"a": "E", "b": 81}, {"a": "F", "b": 53},
{"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52}
]
},
"layer": [{
"mark": "bar",
"encoding": {
"x": {"field": "a", "type": "nominal", "axis": {"labelAngle": 0}},
"y": {"field": "b", "type": "quantitative"},
"color": {
"field": "b", "type": "quantitative",
"scale": {"type": "linear", "scheme": "redblue", "domainMid": -20}
}
}
}, {
"mark": "text",
"encoding": {
"color": {"datum": -20}
}
}]
}
then the color legend looks nice.
Because the in the Vega output we now have
"domain": {"fields": [{"data": "data_0", "field": "b"}, [-20]]},
instead of just "domain": {"data": "data_0", "field": "b"}.
Metadata
Metadata
Assignees
Labels
No labels