Published
Edited
Apr 11, 2020
1 fork
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
html`<link rel="stylesheet" href="//rawgithub.com/Caged/d3-tip/master/examples/example-styles.css">
<style>
.rect:hover {
opacity: 0.7;
}
`

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
md`# Sunburst`
Insert cell
md`probably will actually quilt`
Insert cell
piechart = {
const arcs = pie(pieData);

const svg = d3.create("svg")
.attr("viewBox", [-width / 2, -height / 2, width, height]);

svg.selectAll("path")
.data(arcs)
.join("path")
.attr("fill", (d) => d3.interpolateViridis(d.data.count/592))
.attr("d", arc)

svg.append("g")
.attr("font-family", "sans-serif")
.attr("font-size", 12)
.attr("text-anchor", "middle")
.selectAll("text")
.data(arcs)
.join("text")
.attr("transform", d => `translate(${arc.centroid(d)})`)
.call(text => text.append("tspan")
.attr("y", "-0.4em")
.attr("font-weight", "bold")
.text(d => d.data.name))
.call(text => text.filter(d => (d.endAngle - d.startAngle) > 0.25).append("tspan")
.attr("x", 0)
.attr("y", "0.7em")
.attr("fill-opacity", 0.7)
.text(d => d.data.value.toLocaleString()));

return svg.node();
}
Insert cell
pieData = {
const data = d3.csvParse(await FileAttachment("totalfreq@1.csv").text(), d3.autoType);
var data2 = data.slice(235, 1196)
return data2;
}
Insert cell
pieHeight = 800;
Insert cell
arc = {
// radius is 400
const radius = Math.min(width, height) / 2;
return d3.arc().innerRadius(radius * 0.5).outerRadius(radius - 1);
}
Insert cell
pie = d3.pie()
.padAngle(0.00000005)
.sort(null)
.value(d => 1)
Insert cell
Insert cell
bigpiechart = {
const arcs = monthpie(bigpieData);

const svg = d3.create("svg")
.attr("viewBox", [-width / 2, -900 / 2, width, 900]);
svg.call(pieTip);
console.log(arcs);
var big = svg.selectAll("path")
.data(arcs)
.join("path")
.attr("fill", (d) => d3.interpolateYlGnBu(d.data.count/6131))
.attr("d", arc)
.attr("class", "slice")
.on('mouseover', pieTip.show)
.on('mouseout', pieTip.hide);
return svg.node();
}
Insert cell
Insert cell
Insert cell
Insert cell
bigpieData = {
const data = d3.csvParse(await FileAttachment("newdf@2.csv").text(), d3.autoType);
return data;
}
Insert cell
html`<style>.slice:hover{opacity:0.8;}</style>`
Insert cell
monthpie = d3.pie()
.padAngle(0.005)
.sort(null)
.value(d => 1)
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