Published
Edited
Apr 30, 2021
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
family
Insert cell
Insert cell
Insert cell
Insert cell
d3 = require("d3@6");
Insert cell
uv = require("unipept-visualizations@2");
Insert cell
Insert cell
{
const sunburstElement = simpleSunburst; // or something like document.selectElementById("simpleTree");
new uv.Sunburst(sunburstElement, family);
}
Insert cell
simpleSunburst = html`<div id="simpleSunburst"></div>`
Insert cell
Insert cell
Insert cell
Insert cell
tooltipDiv = html`<div id="sunburstTooltip"></div>`
Insert cell
{
const sunburstElement = tooltipDiv;
const sunburst = new uv.Sunburst(sunburstElement, JSON.parse(JSON.stringify(taxonomy)), {
getTooltipText: (d) => {
let numberFormat = d3.format(",d");
return (
numberFormat(!d.selfCount ? "0" : d.selfCount) +
(d.selfCount && d.selfCount === 1 ? " sequence" : " sequences") +
" specific to this level<br/>" +
numberFormat(!d.count ? "0" : d.count) +
(d.count && d.count === 1 ? " sequence" : " sequences") +
" specific to this level or lower"
);
}
});
}
Insert cell
Insert cell
colorDiv = html`<div id="sunburst2"></div>`
Insert cell
{
const sunburstElement = colorDiv;
const sunburst = new uv.Sunburst(sunburstElement, JSON.parse(JSON.stringify(taxonomy)), {
colorPalette: ["#FF0000", "#00FF00", "#0000FF"]
});
}
Insert cell
Insert cell
sizeDiv = html`<div id="sunburst3"></div>`
Insert cell
{
const sunburstElement = sizeDiv;
const sunburst = new uv.Sunburst(sunburstElement, JSON.parse(JSON.stringify(taxonomy)), {
radius: 100,
levels: 2,
width: 900,
height: 250
});
}
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