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

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