当有人点击数据上的点时,我想调用自定义函数来显示一些图像或信息。我在 ObservableHQ 笔记本中使用 Vega-lite 却找不到答案?
const chart = (type)=>{
return vl
.markCircle({size: 15, opacity: 0.9})
.autosize('fit')
.data(getData(type))
.encode(
vl.x().fieldQ('slice').title('Slice'),
vl.y().fieldQ('dice').title(type).scale({domain: [0, 1.0]}),
vl.color().field('algorithm').title('Algorithm'),
vl.tooltip(['slice', 'algorithm', 'dice'])
)
}
const types = ['DSC','SDSC_2mm']
const charts = []
types.map(type => {
charts.push(chart(type))
})
return vl.vconcat(vl.hconcat(charts)).render()
}
This is the code I have in notebook.