Skip to content

Commit

Permalink
Graph incomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
BabaVasss committed Mar 18, 2024
1 parent 8255f6e commit 087fa2c
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions 2_2_distributions/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,20 @@ d3.csv("../data/MoMA_distributions.csv", d3.autoType)
.range([height - margin.bottom, margin.top])

//Create new scale to reflect artist's lifespan
const sizeScale = d3.scaleLinear()
.domain("Artist Lifespan")
.range(["blue"])
//.range(["red", "blue", "purple"])
const sizeScale = d3.scaleOrdinal()
.domain(["Artist Lifespan"])
//.domain("Artist Lifespan")
//range([0, d3.max(data, d => d.Artist Lifespan)])
.range(["size"])

/* HTML ELEMENTS */
// svg
const svg = d3.select("#container")
.append("svg")
.attr("width", width)
.attr("height", height)
.attr("viewBox", [0, 0, width, height])
.attr("style", "max-width: 100%; height: auto;")

// axis scales
const xAxis = d3.axisBottom(xScale)
Expand All @@ -46,13 +49,26 @@ d3.csv("../data/MoMA_distributions.csv", d3.autoType)
.call(yAxis);

// circles
const dot = svg
svg.append("g")
.selectAll("circle")
.data(data, d => d.ArtistBio) // second argument is the unique key for that row
.data(data) // second argument is the unique key for that row
.join("circle")
.attr("cx", d => xScale(d.width))
.attr("cy", d => yScale(d.length))
.attr("r", radius)
.attr("fill", d => sizeScale(d.Artist))
.attr("fill", d => sizeScale(d.ArtistLifespan))
//.call(sel => sel.transition()
//.delay(500)
//.duration(1500)
//.attr("cx", d => xScale(d.width))
//.attr("cy", d => yScale(d.length)))

// svg.selectAll(".bar")
// .data(data)
// .join("rect")
// .attr("class", "bar")
// .attr("x", 0 + margin)
// .attr("y", d => yScale(d.Nationality))
// .attr("width", d => xScale(d.Count))
// .attr("height", yScale.bandwidth())
});

0 comments on commit 087fa2c

Please sign in to comment.