Published
Edited
Feb 15, 2021
1 star
Insert cell
md`# pie_chart_key_value`
Insert cell
d3 = require('d3')
Insert cell
{var pieDiv = DOM.element("pie-chart");

var traceA = {
type: "pie",
values: [8123, 78, 2703, 4579, 64664, 10045, 1324, 54619],
labels: ["Violent crime", 'murder', 'Robbery', 'Aggravated assault', "Property crime" , "Burglary", "rape", "theft"]
};

var data = [traceA];

var layout = {
title: "Crimes for Connecticut"
};

Plotly.newPlot(pieDiv, data, layout);
return pieDiv;
}
Insert cell
Plotly = require("https://cdn.plot.ly/plotly-latest.min.js")
Insert cell
data = d3.csvParse(await FileAttachment("pie_chart@2.csv").text(), d3.autoType)
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