Public
Edited
Feb 5, 2024
1 star
Insert cell
Insert cell
mushroomMap = bertin.draw({
params: { background: "#999999", projection:epsg2154, extent:paris,margin:25},
layers: [
{
type: "header",
text: `Comparaison des connexions sur hotspot wifi gratuit`,
background:"#999999",
fontColor:"#ffffff",
fontSize: 20,
fontFamily:"Roboto"
},
{
type: "label",
geojson: champigons,
values: "name",
},{
type: "mushroom",
geojson: champigons,
top_values:"other",
bottom_values:"apple",
leg_title: ` `,
leg_x: 50,
leg_y: 50,
leg_top_txt: "Autres",
leg_bottom_txt: "Apple",
leg_fontSize: 17,
leg_fontFamily:"Roboto"
},{
type: "layer",
geojson: paris,
fill: "#f7da4899",
stroke: "#666666",
strokeWidth: 1
}
]
})
Insert cell
Insert cell
bertin = require("bertin@1.8")
Insert cell
wifi = d3.json(
"https://opendata.paris.fr/api/explore/v2.1/catalog/datasets/paris-wi-fi-utilisation-des-hotspots-paris-wi-fi/records?select=code_site%2C%20device_constructor_name%2C%20count(datetime)%20as%20nb%2C%20envelope(geo_shape)%20as%20geo&where=code_site%20is%20not%20null&group_by=code_site%2C%20device_constructor_name&order_by=code_site%20ASC&exclude=code_site%3A%23N%2FA"
)
Insert cell
points_wifi = FileAttachment("sites-disposant-du-service-paris-wi-fi.geojson").json()
Insert cell
paris = FileAttachment("arrondissements.geojson").json()
Insert cell
data_geojson= wifi.results.map(function(r){return {type:"Feature",geometry: {type: r.geo.type,coordinates:r.geo.coordinates} ,properties:{code:r.code_site, brand:r.device_constructor_name, nb:r.nb}}})
Insert cell
data_geojson
Insert cell
Insert cell
data_merged = bertin.merge(points_wifi, "idpw", wifi.results.filter(d => d.device_constructor_name == select), "code_site")
Insert cell
epsg2154 = "+proj=lcc +lat_0=46.5 +lon_0=3 +lat_1=49 +lat_2=44 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs"


Insert cell
brands = new Set(wifi.results.map(d=> d.device_constructor_name))
Insert cell
viewof select = Inputs.select([...brands], {label: "Select one"})
Insert cell
centroidMap = bertin.draw({
params: { background: "#bde1f0", margin: 10, projection : epsg2154},
layers: [
{
type: "header",
text: `Nombre de connexion ${select} par hotspot Wifi`,
fontSize: 20,
fontFamily:"Roboto"
},
{
type: "bubble",
geojson: data_merged,
k:50,
values: "nb",
leg_x: 50,
leg_y: 50
},
{
type: "layer",
geojson: paris,
fill: "#f7da48",
stroke: "#6eb5e0",
strokeWidth: 1
}
]
})
Insert cell
Insert cell
map_site = d3.group(wifi.results,d=>d.code_site)
Insert cell
data_merged_loc_allbrands = points_wifi.features.map(function(d){
let res = map_site.get(d.properties.idpw);
if(res){
let apple = res.filter(d=>d.device_constructor_name=="Apple").length>0?res.filter(d=>d.device_constructor_name=="Apple")[0].nb:0;
let other = res.filter(d=>d.device_constructor_name!="Apple").map(cv=>cv.nb).reduce((val,cval)=>cval+val)
return {code:d.properties.idpw,apple:apple,other:other}
}
return {code:d.properties.idpw,apple:0,other:0}
})
Insert cell
champigons = bertin.merge(points_wifi,"idpw",data_merged_loc_allbrands.filter(d=>d.code),"code")
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