Public
Edited
Nov 27, 2023
Importers
6 stars
Insert cell
Insert cell
toc()
Insert cell
Insert cell
Insert cell
Insert cell
heading("<strong>Load File</strong> 🧐 check input data", 2, 5)
Insert cell
heading("<strong>Load File</strong> 🧐 check input data", 2, 10, "blue")
Insert cell
heading("<strong>Load File</strong> 🧐 check input data", 7, 15, "red")
Insert cell
heading("<strong>Load File</strong> 🧐 check input data", 7, 15, "brown")
Insert cell
heading("<strong>Load File</strong> 🧐 check input data", 7, 15, "purple")
Insert cell
Insert cell
Insert cell
// see https://observablehq.com/@tomlarkworthy/view
viewof composite = view`<div style="display: flex; justify-content:space-between; ">
<div style="display: flex-column;">
<div>${[
"r1",
Inputs.range([0, 10], { value: 0, label: "Secret number:" })
]}</div>
<div>${[
"r2",
Inputs.range([0, 3], { value: 1, label: "Another magic number:" })
]}</div>
<div>${[
"text",
Inputs.text({
label: "Enter some text"
})
]}</div>
</div>
<img width="150"src="https://media.giphy.com/media/2vobTwCkFg88ZUnilt/giphy-downsized.gif"></img>
</div>
`
Insert cell
viewof objectCollection2 = view`<div style="text-align:center;font-size:30px">Title</div><div style="display: grid; grid-template-columns: repeat(2, 1fr);">
<div><h4>Scales</h4>${[
"...",
{
number: Inputs.range([0, 10], { value: 0, label: "Secret number1:" }),
number2: Inputs.toggle({ label: "On / Off" }),
number3: Inputs.range([0, 10], {
value: 0,
label: "Number3 :"
}),
text: Inputs.text()
}
]}</div>
<div>${[
"...",
{
number: Inputs.range([0, 10], { value: 0, label: "Secret number1:" }),
number2: Inputs.range([0, 10], { value: 0, label: "Secret2:" }),
number3: Inputs.range([0, 10], {
value: 0,
label: "Number3 :"
}),
text: Inputs.text()
}
]}</div>
<div>${[
"...",
{
number: Inputs.range([0, 10], { value: 0, label: "Secret number1:" }),
number2: Inputs.range([0, 10], { value: 0, label: "Secret2:" }),
number3: Inputs.range([0, 10], {
value: 0,
label: "Number3 :"
}),
text: Inputs.text()
}
]}</div>
</div>`
Insert cell
viewof toggle = Inputs.toggle({label: "On / Off"})
Insert cell
viewof objectCollection = view`${[
"...",
{
number: Inputs.range([0, 10], { value: 0, label: "Secret number1:" }),
number2: Inputs.range([0, 10], { value: 0, label: "Secret2:" }),
number3: Inputs.range([0, 10], {
value: 0,
label: "Number3 :"
}),
text: Inputs.text()
}
]}`
Insert cell
composite
Insert cell
Insert cell
viewof year = rangeSlider({
title: "year",
description: "Filter to a range",
min: 1990,
max: 2020,
step: 1
})
Insert cell
year
Insert cell
viewof range = Inputs.range([0, 100], {label: "Amount"})
Insert cell
Insert cell
In the chart below, we can see ${textcolor('AMZN', d3.schemeTableau10[1])} overtaking ${textcolor('GOOG', d3.schemeTableau10[2])} between 2016 and 2018.
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
(1233647852.456789).toLocaleString() // format a number
Insert cell
new Date(2018, 11, 1, 9, 27, 9, 247).toLocaleString("de-DE", {
day: "numeric",
month: "numeric",
year: "numeric"
})
Insert cell
new Date(2018, 11, 1, 9, 27, 9, 247).toLocaleString("fr-FR", {
day: "numeric",
month: "numeric",
year: "numeric"
})
Insert cell
new Date(2018, 11, 1, 9, 27, 9, 247).toLocaleString("en-US", {
day: "numeric",
month: "numeric",
year: "numeric"
})
Insert cell
new NumberParser("de").parse("100.000,3")
Insert cell
d3.utcParse("%d.%m.%Y")("10.2.2010")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
orientation === "vertical"
? html`<div>${plot1()}${plot2()}</div>`
: html`<div style="display: flex">${plot1()}${plot2()}</div>`
Insert cell
html`${plot1()}`
Insert cell
function plot1() {
return Plot.plot({
marks: [Plot.areaY(aapl, { x: "Date", y: "Close" }), Plot.ruleY([0])]
});
}
Insert cell
plot2()
Insert cell
function plot2() {
return Plot.plot({
marks: [Plot.dot(cars, { x: "power (hp)", y: "economy (mpg)" })]
});
}
Insert cell
//html`${plot1}`
Insert cell
Insert cell
function heading(
titleHTML = "Load data",
step = 1,
stepsTotal = 10,
color = "green"
) {
const containerStyle = "h-container-" + color;
const squareStyle = "h-square h-completed-" + color;
return html`
<style>
.h-container-green {
background-color: #C1E1C1;
}
.h-container-blue {
background-color: #d8eff3;
}
.h-container-red {
background-color: #ffdacc;
}
.h-container-brown {
background-color: #f5deb3;
}
.h-container-purple {
background-color: #e6e6fa;
}
.h-square {
padding-left: 5px;
padding-right: 5px;
text-align: center;
border: 1px outset;
}
.h-completed-green {
border-color: darkgreen;
background-color: green;
color: white;
}
.h-completed-blue {
border-color: darkblue;
background-color: steelblue;
color: white;
}
.h-completed-red {
border-color: darkred;
background-color: #b22222;
color: white;
}
.h-completed-brown {
border-color: black;
background-color: #a0522d;
color: white;
}
.h-completed-purple {
border-color: black;
background-color: #6a5acd;
color: white;
}
.h-not-completed {
border: 1px outset darkgrey;
background-color: white;
color: grey;
}
</style>
<div class=${containerStyle} style="padding:5px;border-radius:5px;">
${Array.from({ length: stepsTotal }, (_, i) => i + 1).map((ele) =>
ele <= step
? htl.html.fragment`<span class=${squareStyle}>${ele}</span>`
: htl.html.fragment`<span class="h-square h-not-completed">${ele}</span>`
)}
<span style="padding-left:15px">${titleHTML}</div>
</span>`;
}
Insert cell
Insert cell
import { view } from "@tomlarkworthy/view"
Insert cell
import { toc } from "@mbostock/toc"
Insert cell
// import { toc } from "@bryangingechen/toc"
Insert cell
import { rangeSlider } from "@mootari/range-slider"
Insert cell
import { textcolor } from "@observablehq/text-color-annotations-in-markdown"
Insert cell
import { NumberParser } from "@mbostock/localized-number-parsing"
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