Published
Edited
Nov 16, 2021
1 fork
Importers
Insert cell
Insert cell
Insert cell
Insert cell
viewof _regionSelector = Inputs.radio(["Europe", "SpainCCAA"], {
label: "Region",
value: "SpainCCAA" // 👈🏻 Default value
})
Insert cell
isEurope = _regionSelector === "Europe"
Insert cell
dataset = isEurope ? datasetGeneral : datasetCCAA
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
_myRegionData = isEurope ? myCountryData : myCCAAData
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof _myRegionAccess = Inputs.radio(
["Yes", "No", "Depends", "NotAvailable"],
{
value: "Yes",
label: "Regions access"
}
)
Insert cell
resumeRegionAccessLegalAge = html`
${
_myRegionAccess === "Yes"
? chunkAccessYesCCAA
: _myRegionAccess === "No" ||
_myRegionData.region_code === "MD" ||
_myRegionData.region_code === "IB"
? chunkAccessNoCCAA
: _myRegionAccess === "Depends"
? chunkAccessDependsCCAA
: chunkAccessNotAvailableCCAA
}
`
Insert cell
chunkAccessYesCCAA = html`
${locale[_languageSelector].chunkAccessYesCCAA}
`
Insert cell
chunkAccessDependsCCAA = html`
${locale[_languageSelector].chunkAccessDependsCCAA}
`
Insert cell
chunkAccessNoCCAA = html`
${locale[_languageSelector].chunkAccessNoCCAA}
`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
myCountryData
Insert cell
_myRegionData
Insert cell
ageLegalNotesExtraCCAA = html`

<div class="ART-note">

${
_myRegionData.age_notes
? `<p>${_myRegionData.age_notes}
</p>
`
: ""
}

</div>

`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//filterFromBlackToColorNoAccess = "invert(0.4) sepia(1) saturate(4) hue-rotate(305deg)"
Insert cell
//filterFromBlackToColorAccess = "invert(0.5) sepia(1) saturate(4) hue-rotate(140deg)"
Insert cell
//filterFromBlackToDepends = "invert(0.7)"
//filterFromBlackToDepends = "invert(0.51) sepia(0.21) saturate(4.47) hue-rotate(253deg) brightness(0.93) contrast(0.89)"
Insert cell
Insert cell
Insert cell
// Adding date as parameter to avoid cache problems with any data update
dateId = new Date().getTime()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Inputs.table(datasetCCAARaw)
Insert cell
publicFundingFemaleMaxAgeCCAA = 40
Insert cell
publicFundingFemaleMinAgeCCAA = 18
Insert cell
publicFundingMaleMaxAgeCCAA = 100 // Convention to show "Sin Límite"
Insert cell
publicFundingMaleMinAgeCCAA = 18
Insert cell
datasetCCAA = {
const data = await d3.csv(
URLdataset_CCAA,
({ region_code_ISO, region_name, age_viz, age_notes_formattedCopy }) => ({
region_code: region_code_ISO,
region_name: region_name,
// Three possible answers: "Yes", "Depends" or "NotAvailable"
female_maxAge:
age_viz.trim() === "Yes"
? publicFundingFemaleMaxAgeCCAA
: age_viz.trim(),
female_minAge: publicFundingFemaleMinAgeCCAA,
male_maxAge: publicFundingMaleMaxAgeCCAA,
male_minAge: publicFundingMaleMinAgeCCAA,
age_notes: age_notes_formattedCopy
})
);

// Sorting by region name alphabetically
return data
.filter((d) => d.region_code !== "")
.sort((a, b) => d3.ascending(a.region_name, b.region_name));
}
Insert cell
Inputs.table(datasetCCAA)
Insert cell
regions = datasetCCAA.map((d) => d.region_code)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
datasetGeneralRaw = await d3.csv(URLdataset_general, d3.autoType)
Insert cell
datasetGeneral = {
const data = await d3.csv(
URLdataset_general,
({
country_code,
country_name,
female_minAge,
female_maxAge,
male_minAge,
male_maxAge,
limited_byAge
}) => ({
country_code: country_code,
country_name: country_name,
female_minAge:
female_minAge === "No"
? 1
: female_minAge === "reproductive age" ||
female_minAge === "NotAvailable"
? female_minAge
: +female_minAge,
female_maxAge:
female_maxAge === "No"
? 100
: female_maxAge === "reproductive age" ||
female_maxAge === "NotAvailable"
? female_maxAge
: +female_maxAge,
male_minAge:
male_minAge === "No"
? 1
: male_minAge === "reproductive age" || male_minAge === "NotAvailable"
? male_minAge
: +male_minAge,
male_maxAge:
male_maxAge === "No"
? 100
: male_maxAge === "reproductive age" || male_maxAge === "NotAvailable"
? male_maxAge
: +male_maxAge,
limited_byAge: limited_byAge
})
);

// Sorting by country name alphabetically
return data
.filter((d) => d.country_code !== "")
.sort((a, b) => d3.ascending(a.country_name, b.country_name));
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
_myRegionData
Insert cell
Insert cell
locale = ({
es: {
dontApply: "No aplica",
notAvailable: "No disponible",

/// REGIONS

chunkAccessYesCCAA: `<p class="resume-access-yes">En <span class="access-yes">${_myRegionData.region_code}: ${_myRegionData.region_name}</span> se cumplen los límites nacionales: 40 años "al inicio del estudio del paciente" (38 en inseminación con semen de pareja).
</p>`,

chunkAccessDependsCCAA: `<p class="resume-access-depends">En <span class="access-depends">${_myRegionData.region_code}: ${_myRegionData.region_name}</span> tienen la siguiente interpretación:
</p>`,

chunkAccessNoCCAA: `<p class="resume-access-no">En <span class="access-no">${_myRegionData.region_code}: ${_myRegionData.region_name}</span> tienen la siguiente intepretación:
</p>`,

chunkAccessNotAvailableCCAA: `<p class="resume-access-notAvailable">Información no disponible en <span class="access-notAvailable">${_myRegionData.region_code}: ${_myRegionData.region_name}</span></p>`
}
})
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