Public
Edited
Oct 20, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
colorConfig = ({ domain: properties, range: d3.schemeCategory10 })
Insert cell
properties = _.uniq(data.map((d) => d.Property))
Insert cell
data = {
let rv = rawData
.map((d) => {
return {
...d,
Extracted_name: parseName(d.Extracted_name),
Value: +d.Value,
Unit: parseUnits(d.Unit),
Date: new Date(d.Date)
};
})
.map((d) => {
if (
(d.Unit[0] === "Ampere^(1.0)",
d.Unit[1] === "Hour^(1.0)",
d.Unit[2] === "KiloGram^(-1.0)")
) {
d.Value *= 1e6;
d.Unit = ["Gram^(-1.0)", "Hour^(1.0)", "MilliAmpere^(1.0)"];
}
return d;
});
return d3.sort(rv, (d) => d.Date);
}
Insert cell
rawData = (await FileAttachment("battery_merged.json.zip").zip())
.file("battery_merged.json")
.json()
Insert cell
function parseUnits(s) {
return s.split(/ {2,}/);
}
Insert cell
function parseName(s) {
let parsed;
try {
parsed = JSON.parse(s);
} catch {
parsed = JSON.parse(s.replace(/'/g, '"'));
}

return parsed.map((d) =>
Object.fromEntries(
Array.from(Object.entries(d)).map(([key, value]) => [key, +value])
)
);
}
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