Public
Edited
May 31, 2023
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
//viewof favorite = Inputs.select(iris, {["Sepal_Length", "Sepal_Width", "Petal_Length", "Petal_Width"]})

Insert cell
Insert cell
width = 400
Insert cell
height = 400
Insert cell
margin = ({top: 20, right: 20, bottom: 120, left: 40})
Insert cell
x = d3.scaleLinear() // Escala lineal
.domain([0, d3.max(iris.map(function(d) { return d[campo_x] } ) )])// requiere un dominio 0 -> max(cantidad)
.range([margin.left, width - margin.right]) // y un rango en la gráfica: márgenes laterales
Insert cell
Insert cell
Insert cell
Insert cell
y = d3.scaleLinear() // Escala lineal
.domain([0, d3.max(iris.map(function(d) { return d[campo_y] } ) )])// requiere un dominio 0 -> max(cantidad)
.range([height - margin.bottom, margin.top]) // y un rango en la gráfica: márgenes laterales
Insert cell
xAxis = function (g){
return g.attr("transform", `translate(0,${height - margin.bottom})`) // Esta línea llama al método transform y a translate y "desplaza" el eje dibujado desde 0 y movido sobre el eje Y en height - margin.bottom pixeles
.call(d3.axisBottom(x))
}
Insert cell
yAxis = function (g){ return g.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y))}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {select} from "@jashkenas/inputs"

Insert cell
iris.map(function(d) { return d[campo_y] } )
Insert cell
campo_y
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