Public
Edited
Jan 17
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
viewof TW = TimeWidget(data, {
x: xAttr,
y: yAttr,
id: IdAttr,
xLabel: "→ " + labelX,
yLabel: "↑ " + labelY,
hasDetails: hasDetails,
doubleYlegend: doubleYlegend,
showGrid: showGrid,
selectedAlpha: selectedAlpha,
noSelectedAlpha: noSelectedAlpha,
maxDetailsRecords: 10,
showBrushTooltip: true,
width: width,
detailsWidth: width,
showBrushesControls: false,
referenceCurves: curvas,

_this: this
})
Insert cell
viewof hasDetails = Inputs.toggle({label: "Show Details", value: false})
Insert cell
viewof showGrid = Inputs.toggle({label: "Show Grid", value: true})
Insert cell
viewof doubleYlegend = Inputs.toggle({label: "Show Double Y Legend", value: true})
Insert cell
Insert cell
viewof IdAttr = Inputs.select(attribs, {
value: "Code",
label: "ID variable"
})
Insert cell
viewof xAttr = Inputs.select(attribs, {
value: "__time",
label: "X Variable"
})
Insert cell
viewof yAttr = Inputs.select(attribs, {
value: "peso",
label: "Y variable"
})
Insert cell
viewof labelX = Inputs.text({label: "Label X: ", value: "Gestational Age (weeks)"})
Insert cell
viewof labelY = Inputs.text({label: "Label Y: ", value: "Weight (gr)"})
Insert cell
viewof data = dataInput({value: dataStages})
Insert cell
mainView = viewof TW
Insert cell
groups = viewof TW.groups
Insert cell
brushesCoordinates = viewof TW.brushesCoordinates
Insert cell
dataStages
Insert cell
Insert cell
/*brushDetails = {
const brushesElements = Array.from(selected.brushes.entries())
.map(([brushGroupid, bgm]) => {
const brushesElements = Array.from(bgm.entries()).map(([brushId, b]) => {
if (!b.selection) return;
return htl.html`<div>
<div>Selected: ${b?.isSelected} Active: ${b?.isActive}</div>

<label>From: <output class="x0" contenteditable="true">${fmtX(
b.selection[0][0]
)}</output> <strong>x</strong> <output class="y0" contenteditable="true">${fmtY(
b.selection[0][1]
)} </output >
</label>
<br/>
<label>To: <output class="x1" contenteditable="true">${fmtX(
b.selection[1][0]
)}</output> x <output class="y1" contenteditable="true">${fmtY(
b.selection[1][1]
)}</output>
</label>
</div>`;
});

const detailsEle = htl.html`<details>
<summary>Group <svg width=20 height=20>
<rect fill=${viewof selected.ts.colorScale(
brushGroupid
)} width=20 height=20></rect>
</svg>
</summary>
${brushesElements}
</details>
`;

// Open if it contains the current one
if (
Array.from(bgm.values())
.flat()
.filter((b) => b.isActive).length
)
detailsEle.querySelector("details").setAttribute("open", null);
return detailsEle;
})
.flat();

return htl.html`
<form action="">
<h2>Brushes</h2>
${brushesElements}
<button>Update</button>
</form>
`;
}*/
Insert cell
fmtY = d3.format(".2d")

Insert cell
fmtX = d3.format(".1f")
Insert cell
width = 700
Insert cell
dataStages = transformData(dDataFilter, "Code", stages)
.filter(
(d) => d["peso"] < 15000 && d["__time"] > 20 && d["__time"] < 93
)
Insert cell
dataF = data.slice(0,maxTimelines)
Insert cell
attribs = Object.keys(data[0])
Insert cell
dDataFilter = defaultData.filter(d => d["ERN_Ballard"] < 50 && d["ERN_Ballard"] > 20)
Insert cell
defaultData = FileAttachment("KMC-50k-Base 1993-2022 Jul -20220929.csv.zip")
.zip()
.then((res) => res.file("KMC-50k-Base 1993-2022 Jul -20220929.csv").csv({ typed: true }))
Insert cell
curvas = FileAttachment("curvasv2.json").json()
Insert cell
import {transformData,stages} from "@ivelascog/to-stages"
Insert cell
import { dataInput } from "@john-guerra/data-input"
Insert cell
TimeWidget = {
try {
return await require(`http://localhost:8080/dist/TimeWidget.js?${Date.now()}`);
} catch (e) {
return await require("time-widget");
}
}
Insert cell
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