Published
Edited
Jul 2, 2020
1 fork
3 stars
Insert cell
md`# Radar plotly`
Insert cell
radarData = FileAttachment("radar_list_norm@1.txt").json()
Insert cell
{
const data = radarData.map(d => ({
type: 'scatterpolar',
r: d.dati.map(s => s.value).concat(d.dati.map(s => s.value)[0]), // .concat(...) serve per copiare il primo valore della serie in fondo all'array. Serve per chiudere la line
theta: d.dati.map(s => s.axis).concat(d.dati.map(s => s.axis)[0]),
// fill: 'toself', // crea il riempimento
name: d.nome,
visible: d.nome == "Toscana" ? true : 'legendonly',
opacity: 0.5,
line: {
width: 2,
shape: 'spline' // questo crea uno smooth delle linee
// color: 'red' // qui potete passare una funzione per assegnare colori personalizzati
},
marker: {
size: 8
},
// un template html per formattare il box visibile al passggio del mouse
hovertemplate: '<b>%{theta}</b>' + '<br>%{r:.2f}<br>' + "<extra></extra>"
}));

const layout = {
width: width,
height: (width / 3) * 2,
polar: {
angularaxis: {
linewidth: 1,
color: 'gray',
showline: false
},
radialaxis: {
gridcolor: 'white',
gridwidth: 2,
visible: true,
range: [0, 1.05], // il range dell'asse [min,max]
color: 'gray',
showline: false
},
bgcolor: 'rgb(245,245,245)' // colore di sfondo
}
};

const div = DOM.element('div');
Plotly.newPlot(div, data, layout);
return div;
}
Insert cell
md`## APPENDIX`
Insert cell
d3 = require("d3@5", "d3-sankey@0.12")
Insert cell
Plotly = require("https://cdn.plot.ly/plotly-latest.min.js")
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