viewof dateView_MEDV = vegaSync({
facts,
dims: d => {
return [d.calorie];
},
interactivity: "brush",
counts: true,
normalized: true,
spec: {
title: '卡路里值',
width: w,
layer: [
{
mark: "line",
data: {
name: "counts"
},
encoding: {
x: {
field: "key",
type: "quantitative",
title: "卡路里"
},
y: {
field: "value",
type: "quantitative",
title: "分布指数"
},
color: {
value: "#ccc"
}
}
},
{
mark: "bar",
data: {
name: "counts"
},
selection: {
brush: {
name: "brush",
type: "interval",
encodings: ['x']
}
},
encoding: {
x: {
field: "key",
type: "quantitative"
},
y: {
field: "filtered",
type: "quantitative"
},
color: {
condition: { selection: "brush", value: colorVega },
value: "#bbb"
}
}
}
]
},
invalidation,
visibility
})