Public
Edited
Dec 1, 2022
Insert cell
Insert cell
Insert cell
//import {vl} from "@vega/vega-lite-api-v5"
Insert cell
import {usa, unemp} from "@uwdata/cartographic-visualization"
Insert cell
import {vl} from '@vega/vega-lite-api'
Insert cell
VegaLite = require("vega-embed@5")
Insert cell
import {fromColumns, printTable} from '@uwdata/data-utilities'
Insert cell
d3 = require('d3@7')
Insert cell
L = require('leaflet@1.2.0')
Insert cell
data_income = d3.csv('https://gist.githubusercontent.com/manideepvangari/c9b2e66e9a3f0acc4f782fe6f5290359/raw/0d6979ec774a7a4ff7c938d3e7c23369a2154177/county_data_median_obesity.csv')
Insert cell
data_parsed = {

for(let i=0; i<data_income.length; i++){
data_income[i].Obesity_Percentage = +data_income[i].Obesity_Percentage;
data_income[i].Median_Household_Income = +data_income[i].Median_Household_Income;
}
return data_income
}
Insert cell
Insert cell
vl.markBar({tooltip:true})
.data(data_parsed)
.encode(
vl.x().field('Obesity_Percentage').bin({step: 5 }),
vl.y().fieldQ('Median_Household_Income'),
//vl.size().fieldQ('Obesity_Percentage').scale({range: [1, 60]}),
//vl.x().field("County")
)
.render()
Insert cell
Insert cell
//not used

map = d3.csv('https://gist.githubusercontent.com/manideepvangari/a6f6e79b40f5240aa726c97b5115e0d8/raw/1d00a6eb522713c9431376ce75626546501dc637/mapping.csv')
Insert cell
//not used

map_parsed = {

for(let i=0; i<map.length; i++){
map[i].Obesity_Rate = +map[i].Obesity_Rate;
map[i].Obesity_Rate = +map[i].Obesity_Rate/100;
// data_income[i].Median_Household_Income = +data_income[i].Median_Household_Income;
}
return map
}
Insert cell
//not used
restaurants = d3.csv('https://gist.githubusercontent.com/manideepvangari/196f30bc83f4456d6daf141e7e4cc849/raw/f1d637d73e9b46c6cd9eb4f7a44d833c86b46a8f/rest_map.csv')
Insert cell
Insert cell
x = d3.csv('https://gist.githubusercontent.com/manideepvangari/00a9ff09a8f80ec6dcbebf24d6fa06d7/raw/68be46bfde4141cd5e9fcb4212c3db63c723c3d1/county_data_restaurant_obesity.csv')
Insert cell
x_parsed = {
for(let i=0; i<x.length; i++){
x[i].Obesity = +x[i].Obesity;
}
return x
}
Insert cell
vl.markLine({point: true, opacity: .7, strokeWidth: 3, tooltip: true})
.data(x_parsed)
.encode(
vl.x().fieldN('County').axis({labelAngle: 45}),
vl.y().field('Obesity').bin({step:3}),
vl.size().field('Restaurant_County').count().scale({type: 'log'}).legend({title: 'Restaurants in County'})
//vl.size().fieldQ('Obesity').scale({range:[10, 60]}).legend({title: 'Obesity'}),
// vl.color().fieldN('Obesity').legend(null),
)
.render()
Insert cell
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