Published
Edited
Jun 28, 2018
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
html`<link href="https://libs.cartocdn.com/mapbox-gl/v0.45.0-carto1/mapbox-gl.css" rel="stylesheet" />`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
source = {
const source = new carto.source.Dataset('ne_10m_populated_places_simple')
return source
}
Insert cell
Insert cell
Insert cell
Insert cell
//ls_match is a 0/1 property, so multiplying by that will either show or hide the original
//You can substitute global for viewport in the example below.
viz = {
const viz = new carto.Viz(`
@size: $labelrank,
@multiplier: $ls_match,
@newSize: @size * @multiplier,
@agg_avg: viewportAvg($labelrank),
@agg_total: viewportCount($labelrank),
color: blue,
width: @newSize * @agg_avg
`)
return viz
}
Insert cell
Insert cell
agg_total = viz.variables.agg_total.eval()
Insert cell
agg_avg = viz.variables.agg_avg.eval()
Insert cell
Insert cell
Insert cell
Insert cell
layer = {
const layer = new carto.Layer('layer', source, viz);
return layer
}
Insert cell
Insert cell
layer.addTo(map, 'watername_ocean')
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