Published
Edited
Sep 8, 2020
Insert cell
Insert cell
Insert cell
Insert cell
import { select, color, button, text, checkbox, slider} from "@jashkenas/inputs"
Insert cell
// Load the lodash library
_ = require("lodash")
Insert cell
import { code_styles } from "@info474/utilities"
Insert cell
code_styles
Insert cell
viewof basecolor = color()
Insert cell
viewof sides = slider({ min: 3, max: 11, step: 1 })
Insert cell
svg`
<svg height=300 width=${width}>
${_.range(sides).map(d => {
return `<polygon transform="translate(140,100)" fill="transparent" stroke-width="1" stroke="black"
points="${get_path(d)}"/>`;
})}
<path>
</svg>`
Insert cell
line_path = _.range(sides)
.map(d => [Math.cos(2*Math.PI*(d+1)/sides)*100, Math.sin(2*Math.PI*(d+1)/sides)*100])
.join(' ')
Insert cell
get_path = sides => {
return _.range(sides)
.map(d => [
Math.cos((2 * Math.PI * (d + 1)) / sides) * 100,
Math.sin((2 * Math.PI * (d + 1)) / sides) * 100
])
.join(' ');
}
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