cabana: tooltip won't extend past bounds of plot

main
Andy Haden 2017-06-21 20:26:17 -07:00
parent ecb3cba536
commit afcf25cfe4
2 changed files with 10 additions and 3 deletions

View File

@ -8,6 +8,11 @@ export function swapKeysAndValues(obj, f) {
export function fromArray(arr) {
// arr is an array of array key-value pairs
// like [['a', 1], ['b', 2]]
const pairs = arr.map( ([k,v]) => ({[k]: v}));
return Object.assign(...pairs);
if(pairs.length > 0) {
return Object.assign(...pairs);
} else {
return {};
}
}

View File

@ -237,12 +237,14 @@ export default createClassFromSpec('CanPlot', {
"type": "group",
"from": {"data": "tooltip"},
"interactive": false,
"name": "tooltipGroup",
"encode": {
"update": {
"x": {"scale": "xrelscale", "field": "argmin.xRel"},
"x": [{"test": "inrange(datum.argmin.xRel + 80, domain('xrelscale'))", "scale": "xrelscale", "field": "argmin.xRel"},
{"scale": "xrelscale", "field": "argmin.xRel", "offset": -80}],
"y": {"scale": "yscale", "field": "argmin.y"},
"height": {"value": 20},
"width": {"value": 150},
"width": {"value": 80},
"fill": {"value": "#fff"},
"fillOpacity": {"value": 0.85},
"stroke": {"value": "#aaa"},