Support conditional values in Vega

This commit is contained in:
Luka Jeran 2017-09-18 18:42:17 +02:00 committed by lukaw3d
parent 92f0f8813d
commit c4fe0413fc
2 changed files with 53 additions and 38 deletions

73
types/vega/index.d.ts vendored
View File

@ -406,7 +406,7 @@ declare namespace vg {
description?: string;
from?: Mark.From;
key?: string;
delay?: ValueRef;
delay?: ValueRefs;
/**
* "linear-in" | "linear-out" | "linear-in-out" | "linear-out-in" | "quad-in" | "quad-out" | "quad-in-out" |
* "quad-out-in" | "cubic-in" | "cubic-out" | "cubic-in-out" | "cubic-out-in" | "sin-in" | "sin-out" | "sin-in-out" |
@ -465,54 +465,54 @@ declare namespace vg {
// TODO docs
// -- Shared visual properties
x?: ValueRef;
x2?: ValueRef;
width?: ValueRef;
y?: ValueRef;
y2?: ValueRef;
height?: ValueRef;
opacity?: ValueRef;
fill?: ValueRef;
fillOpacity?: ValueRef;
stroke?: ValueRef;
strokeWidth?: ValueRef;
strokeOpacity?: ValueRef;
strokeDash?: ValueRef;
strokeDashOffset?: ValueRef;
x?: ValueRefs;
x2?: ValueRefs;
width?: ValueRefs;
y?: ValueRefs;
y2?: ValueRefs;
height?: ValueRefs;
opacity?: ValueRefs;
fill?: ValueRefs;
fillOpacity?: ValueRefs;
stroke?: ValueRefs;
strokeWidth?: ValueRefs;
strokeOpacity?: ValueRefs;
strokeDash?: ValueRefs;
strokeDashOffset?: ValueRefs;
// -- symbol
size?: ValueRef;
shape?: ValueRef;
size?: ValueRefs;
shape?: ValueRefs;
// -- path
path?: ValueRef;
path?: ValueRefs;
// -- arc
innerRadius?: ValueRef;
outerRadius?: ValueRef;
startAngle?: ValueRef;
endAngle?: ValueRef;
innerRadius?: ValueRefs;
outerRadius?: ValueRefs;
startAngle?: ValueRefs;
endAngle?: ValueRefs;
// -- area / line
interpolate?: ValueRef;
tension?: ValueRef;
interpolate?: ValueRefs;
tension?: ValueRefs;
// -- image / text
align?: ValueRef;
baseline?: ValueRef;
align?: ValueRefs;
baseline?: ValueRefs;
// -- image
url?: ValueRef;
url?: ValueRefs;
// -- text
text?: ValueRef;
dx?: ValueRef;
dy?: ValueRef;
angle?: ValueRef;
font?: ValueRef;
fontSize?: ValueRef;
fontWeight?: ValueRef;
fontStyle?: ValueRef;
text?: ValueRefs;
dx?: ValueRefs;
dy?: ValueRefs;
angle?: ValueRefs;
font?: ValueRefs;
fontSize?: ValueRefs;
fontWeight?: ValueRefs;
fontStyle?: ValueRefs;
}
export interface ValueRef {
@ -524,8 +524,11 @@ declare namespace vg {
mult?: number;
offset?: number;
band?: boolean;
test?: string;
}
export type ValueRefs = ValueRef | ValueRef[];
export var parse: Parse;
export namespace scene {
export function item(mark: Node): Node;

View File

@ -1957,6 +1957,13 @@ specs[20] = {
]
}
const hoverFill21: Vega.ValueRefs = [{
"test": "datum.value < 30",
"value": "#f00"
}, {
"value": "#f55"
}];
specs[21] = {
"name": "wordcloud",
"width": 400,
@ -2006,10 +2013,15 @@ specs[21] = {
"text": { "field": "data.text" }
},
"update": {
"fill": { "value": "steelblue" }
"fill": [{
"test": "datum.value < 30",
"value": "steelblue"
}, {
"value": "blue"
}]
},
"hover": {
"fill": { "value": "#f00" }
"fill": hoverFill21
}
}
}
@ -2020,4 +2032,4 @@ specs.forEach(spec => {
vg.parse.spec(spec, chart => {
chart({el:"#vis"}).update();
});
});
});