Published
Edited
Feb 5, 2021
3 forks
3 stars
Insert cell
Insert cell
Insert cell
import {kmeans} from "@spond/k-means-clustering-algorithm"
Insert cell
Insert cell
data = formatData(cars)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof cluster_chart = {
kmeans(data, clusters)
return vl.markPoint()
.data(data)
.encode(
vl.x().fieldQ("x").title(x),
vl.y().fieldQ("y").title(y),
vl.color().fieldN("cluster"),
vl.tooltip([x, y, 'Name', 'cluster'])
)
.render()
}
Insert cell
Insert cell
function formatData (local_data) {
let new_data = JSON.parse(JSON.stringify(local_data))
new_data.forEach(d => {
d.x = d[x]
d.y = d[y]
})
return new_data
}
Insert cell
Insert cell
import { vl } from "@vega/vega-lite-api"
Insert cell
import {Range, Select} from "@observablehq/inputs"
Insert cell
d3 = require("d3@6")
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more