Published
Edited
May 4, 2020
Insert cell
md`# Covid `
Insert cell
//graphChoice(typeOfGraph)
Insert cell
Insert cell
Insert cell
Insert cell
viewof optionsCheckbox = {
if (metadata_opt(sources,typeOfGraph).length) {
return checkbox({
title: "",
description: "",
options: metadata_opt(sources,typeOfGraph),
submit: false
})
}
else { return undefined}
}

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dataforCircle.map( d => dateToNode[d.XDatef]).filter( d => d )
Insert cell
Insert cell
Insert cell
Insert cell
metadata = ({cases_cum: {name:"Cas cumulés", color:"#f4a582"},
cases_daily: {name:"Cas journalier", color:"#f4a582"},
deaths_all_daily: {name:"Décès totaux journalier", color:"#c2a5cf"},
cases_cum_daily: {name:"Cas journaliers cumulés", color:"#f4a582"},
deaths_hospital_cum_daily: {name:"Décès à l'Hopital cumulés", color:"#c2a5cf"},
deaths_hospital_daily: {name:"Décès à l'Hopital journalier", color:"#c2a5cf"},
deaths_ehpad_cum_daily: {name:"Morts en Ehpad cumulés", color:"#7b3294"},
deaths_ehpad_daily: {name:"Morts en Ehpad journalier", color:"#7b3294"},
deaths_all_cum_daily: {name:"Morts en Ehpad et Hopital cumulés", color:"#000000"},
deaths_all_daily: {name:"Morts en Ehpad et Hopital journalier", color:"#000000"},
ventilated_daily_state: {name:"Réanimation cumulés",color:"#92c5de"},
hospitalized_daily_state: {name:"Hospitalisation cumulées", color:"#ffffbf"},
ventilated_daily_diff: {name:"Réanimation VQ",color:"#92c5de"},
hospitalized_daily_diff: {name:"Hospitalisation VQ", color:"#ffffbf"},
recover_cum_daily: {name:"Retour à domicile cumulés",color:"#a6dba0"},
recover_daily: {name:"Retour à domicile journalier",color:"#a6dba0"},
nm_growth_cases_cum: {name: "Croisance cumulées des cas", color:"#ca0020"},
nm_growth_deaths_cum : {name: "Croissance cumulées des morts", color:"#000000"},
nm_growth_cases_daily: {name:"Croissance cumulée journalière des cas", color:"#ca0020"},
nm_growth_deaths_daily: {name:"Croissance cumulée journalière des décès", color:"#000000"},
rolling_deaths_hospital_daily: {name:"Moyenne mobile des morts à l'hopital", color:"#ca0020"},
rolling_deaths_ehpad_daily: {name:"Moyenne mobile des morts en Ehpad", color:"#ca0020"},
rolling_deaths_all_daily: {name:"Moyenne mobile des morts en totalité", color:"#ca0020"},
rolling_cases_daily: {name:"Moyenne mobile des cas", color:"#ca0020"},
rolling_deaths_daily: {name:"Moyenne mobile des décès", color:"#000000"}})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function getEventData(dataToFilter, getDate) {
return dataToFilter.filter( d => d3.timeDay.count(d3.isoParse(d.data.dateRep), d3.isoParse(getDate) ) === 0);}
Insert cell
Insert cell
metadata_url = "https://api-covid.unthinkingdepths.fr/covid19/metadata"
Insert cell
Insert cell
metadata_keys = Object.keys(metadata_data)
Insert cell
metadata_type = function(g) { return metadata_data[g].type.map(o => ({"label": o.name, "value": o.name}))}
Insert cell
metadata_opt = function(g,t) { return metadata_data[g].type.filter( o => o.name == t)[0]["options"]}
Insert cell
metadata_data = (await d3.json(metadata_url)).data
Insert cell
Insert cell
data_filtered = data.filter(d => (d3.isoParse(d.dateRep).getMonth() >= 2) && d3.isoParse(d.dateRep).getYear() == 120 )
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
optionSeriesFiltered = {
if (optionsCheckbox !== undefined )
{ return optionSeries.map(s => s.filter( d => optionsCheckbox.includes(d.name) )).filter(e => e.length)}
else
{
return "bla"
}
}
Insert cell
Insert cell
Insert cell
Insert cell
re3 = [new RegExp("X")]
Insert cell
colToStack = keys.filter( text => re2.every(re => re.test(text)))
Insert cell
colToDot = keys.filter( text => re.some(re => re.test(text)))
Insert cell
colToDelta = keys.filter( text => re3.some( re => re.test(text)))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
x = d3.scaleTime()
.domain([d3.min(data_filtered.map(d => d3.isoParse(d.dateRep))), d3.max(data_filtered.map(d => d3.isoParse(d.dateRep))) ])
.range([margin.left, viewbox.width - margin.right])

Insert cell
Insert cell
y = d3.scaleLinear()
.domain([0, d3.max(series, d => d3.max(d, d => d[1])) + (60 * d3.max(series, d => d3.max(d, d => d[1])) /100) ])
.rangeRound([viewbox.height - margin.bottom, margin.top])
Insert cell
Insert cell
d3.extent(d3.max(series,d => d.map( x => x.data.growth_cases_cum)))
Insert cell
y2 = d3.scaleLinear()
.domain([getMinfromGrowthSeries,getMaxfromGrowthSeries]).nice()
.rangeRound([viewbox.height - margin.bottom, margin.top])
Insert cell
yAxis2 = g => g
.attr("transform", `translate(${viewbox.width - margin.right} ,0)`)
.call(d3.axisRight(y2).ticks())
.call(g => g.selectAll(".domain2"))
Insert cell
Insert cell
Insert cell
Insert cell
colorsCat_stack = new Map(metadataStackFiltered.map(m=> [m.value, m.label["color"]]))
Insert cell
colorsCat_line = new Map(metadataLineFiltered.map(m=> [m.value, m.label["color"]]))
Insert cell
getMaxfromGrowthSeries = d3.max(optionSeries.map( s => d3.max( s.map( p => p.values))))
Insert cell
getMinfromGrowthSeries = d3.min(optionSeries.map( s => d3.min( s.map( p => p.values))))
Insert cell
color = d3.scaleOrdinal()
.domain(series.map(d => d.key))
.range([...colorsCat_stack.values()])
.unknown("#ccc")
Insert cell
ycolor = d3.scaleOrdinal()
.domain(colToDot)
.range([...colorsCat_line.values()])
.unknown("#ccc")
Insert cell
dotcolor = d3.scaleLinear()
.domain(d3.extent(data_filtered.map( d => d["XDelta"])))
.range(["red","grey"])
Insert cell
d3 = require("d3@5")
Insert cell
Insert cell
import {visualizeTicks} from "@d3/continuous-scales"
Insert cell
import {swatches} from "@d3/color-legend"
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