I looking at different tutorials where the code formatting are different and I’m having trouble translating them.
For example, Tom MacWright’s Tutorial 3: Visualizing data does it this way:
vegalite({
data: { values: alphabet },
mark: “bar”,
autosize: “fit”,
encoding: {
x: {
field: “letter”,
type: “ordinal”
},
y: {
field: “frequency”
}
}
})
while Visnu Pitiyanuvath’s Layers and Facets and Concat, Oh My! looks like this:
viewof layeredBar = vl .data(alphabet) .layer( vl.markBar() .encode( vl.y().fieldN("letter"), vl.x().fieldQ("frequency").axis({ format: "%", grid: false }) ), vl.markText({ align: "left", dx: 5, dy: 1 }) .encode( vl.y().fieldN("letter"), vl.x().fieldQ("frequency"), vl.text().fieldN("frequency").format(".2%") ) ) .render()
How do I include autosize: "fit"
into the latter format?