Public
Edited
May 23, 2023
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
calculatedData = {
return filteredCounties.map(function(feature){
return {
NAME: feature.properties.NAME,
area: feature.properties.ALAND,
logArea: Math.log(feature.properties.ALAND)
}
})
}
Insert cell
Insert cell
deckgl = {
baseMap.innerHTML = '';
const stateLayer = new deck.GeoJsonLayer({
// data:healthFactorsCountyChrr,
data: all_states_no_gc,
getFillColor: [255,0,0,120],
onClick: function(stuff){
const feature = stuff.object
mutable stateName = feature.properties.State
},
pickable: true
})

const mapLayer = new deck.GeoJsonLayer({
data:filteredCounties,
getFillColor: function(dataRow) {
// switch(dataRow.properties.ChickenCount){
// case 1:
// return [255,0,0]
// case 2:
// return [0,0,0]
// default:
// return [255,255,255]
// }
return [0, 255*(dataRow.properties.UnEmplyPrc/10),0, 200]
}
})
return new deck.DeckGL({
// The HTML container to render into
container: baseMap,

// Mapbox settings
// set `map: false` to turn off Mapbox base map
map: mapboxgl,
// This token is for demo-purpose only and rotated regularly. Get your token at https://www.mapbox.com
mapboxApiAccessToken: 'pk.eyJ1IjoidWJlcmRhdGEiLCJhIjoiY2pudzRtaWloMDAzcTN2bzN1aXdxZHB5bSJ9.2bkj3IiRC8wj3jLThvDGdA',
mapStyle: 'mapbox://styles/mapbox/dark-v9',

// Viewport settings
longitude: -90.9712,
latitude: 40.7831,
zoom: 2,
pitch: 0,
bearing: -0,
layers: [
mapLayer,
stateLayer
]
});
}
Insert cell
filteredCounties = healthFactorsCountyChrr.features.filter(
row => {
if (selectedStates.includes(row.properties.State)) {
return true
} else {
return false
}
})
Insert cell
summaryState = {
const unemploymentData = filteredCounties.map(row => row.properties.UnEmplyPrc)
let averageUnemployment = 0
for (let i=0;i<unemploymentData.length;i++) {
averageUnemployment+= unemploymentData[i]
}
return averageUnemployment/unemploymentData.length
}
Insert cell
Insert cell
mutable stateName = "Oregon"
Insert cell
allState = healthFactorsCountyChrr.features.map(feature => feature.properties.State).filter((value, index, array) => array.indexOf(value) === index)
Insert cell
all_states_no_gc = FileAttachment("all_states_no_gc.geojson").json()
Insert cell
Insert cell
Insert cell
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