Published
Edited
Jan 31, 2020
Insert cell
md`# Vegalite Isotype attempt`
Insert cell
Insert cell
Insert cell
html`${monster}`
Insert cell
import {vl} from '@vega/vega-lite-api'
Insert cell
{
const data = [
{x:1, type:'a'},
{x:2, type:'a'},
{x:1, type:'b'},
{x:2, type:'b'},
{x:3, type:'b'},

]
const chart = vl.markPoint()
.data(data)
.encode(
vl.x().fieldO('x'),
vl.y().fieldN('type'),
vl.shape().fieldN('type').scale({domain: ['a', 'b'], range: [monster, monster2]}),
vl.size().value(1.8)
)

return chart.height(100).render()
}
Insert cell
md `### no vegalite`
Insert cell
{
const data = [
{x:1, type:'a'},
{x:2, type:'a'},
{x:1, type:'b'},
{x:2, type:'b'},
{x:3, type:'b'},
]
const div = document.createElement("div")
const a = document.createElement("div")
const b = document.createElement("div")
div.appendChild(a)
div.appendChild(b)
a.appendChild(html`<span>Type a: </span>`)
b.appendChild(html`<span>Type b: </span>`)

// create a mark for each element in the appropriate row.
data.forEach(function(x) {
if (x.type === 'a') a.appendChild(html`${monster}`)
if (x.type === 'b') b.appendChild(html`${monster2}`)

})

return div

}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more