viewof charts2020vsgraph = {
kmeans(top5danceabilitydate);
const scatter_sq = width * 0.50;
const hist_width = width * 0.30;
const num_hist = hist_columns.length;
const brush = vl.selectInterval().encodings('x').resolve('interesect');
const histogram = vl.markBar()
.encode(
vl.x().fieldQ(vl.repeat('row'))
.bin({maxbin:10, minstep:.01})
.axis({titleAnchor:'start'}),
vl.y().count().title(null));
const histogram_layer = vl.layer(
histogram.select(brush).encode(vl.color().value('lightgrey')),
histogram.transform(vl.filter(brush)))
.height((scatter_sq/num_hist)-(10*num_hist))
.width(hist_width)
.repeat({row: hist_columns});
const scatter = vl.markPoint()
.height(scatter_sq).width(scatter_sq)
.encode(
vl.x().fieldQ(x),
vl.y().fieldQ(y),
vl.color().value('purple'),
vl.opacity().if(brush,vl.value(0.8)).value(0.1),
vl.tooltip(quant_columns.concat(['Track Name','Artist']))
)
return vl.hconcat(histogram_layer,scatter)
.data(top5danceabilitydate)
.render();
}