From 81b1b5b29e5cf10b6185ad7f32ff2387798336db Mon Sep 17 00:00:00 2001
From: hadro ${d.Year}
Male: ${d.male}
- Female: ${d.female}`)
+ Male ratio: ${d3.format(".0%")(d.m_ratio)}
+ Female: ${d.female}
+ Female ratio: ${d3.format(".0%")(d.f_ratio)}`)
// .style("left", ((event.x > width/2 + 50) ? event.x + 70 + "px" :event.x + -140 + "px"))
.style("left", event.x + 50 + "px")
.style("top", event.y + 20 + "px")
@@ -212,8 +235,8 @@ svg
.attr("class", "female-ratio")
.attr("id", d => `${d.Year}-${d.female}-${d.f_ratio}-${d.Classification}`)
.attr("year", d => d.Year)
- .attr("x", d=> x(d.Year))
- .attr("y", d=> y(d.f_ratio))
+ .attr("x", d=> x(d.Year) - works(d.female))
+ .attr("y", d=> y(d.f_ratio) - works(d.female))
.attr("rx", 0)
.attr("ry", 0)
.attr("fill", colorScale(2) )
@@ -244,8 +267,8 @@ svg
.attr("class", "male-ratio")
.attr("id", d => `${d.Year}-${d.female}-${d.f_ratio}-${d.Classification}`)
.attr("year", d => d.Year)
- .attr("x", d=> x(d.Year))
- .attr("y", d=> y(d.m_ratio))
+ .attr("x", d=> x(d.Year) - works(d.male))
+ .attr("y", d=> y(d.m_ratio) - works(d.male))
.attr("fill", colorScale(1) )
.attr('fill-opacity', "0.5")
.call(sel => sel
@@ -267,6 +290,11 @@ svg
function circles() {
+ filteredData = state.data
+ .filter(d => d.Classification === state.selectedClassification)
+
+ state.selectedChart = "Ratio";
+
d3.select('.y-axis-top')
// .transition()
// .duration(600)
@@ -336,7 +364,23 @@ svg
.duration(1000)
.call(yAxis);
-
+ mouseHover = function(event, d) {
+ tooltip
+ .style('opacity', "1")
+ .html(`${d.Year}
Male: ${d.male}
+ Male ratio: ${d3.format(".0%")(d.m_ratio)}
+ Female: ${d.female}
+ Female ratio: ${d3.format(".0%")(d.f_ratio)}`)
+ .style("left", event.x+30+"px")
+ .style("top", event.y+30+"px")
+ // .style("left", ((event.x > width/2 + 50) ? event.x + 70 + "px" :event.x + -140 + "px"))
+ // .style("top", event.y + 20 + "px")
+ .transition()
+ svg.selectAll(`rect[year="${d.Year}"]`)
+ .transition()
+ .attr("fill-opacity", "1")
+ .attr("fill", d=> "#aaa" );
+ }
// A function that change this tooltip when the leaves a point: just need to set opacity to 0 again
mouseleave = function(event,d) {
@@ -361,17 +405,18 @@ svg
.data(filteredData, d => d.Year + d.female + d.f_ratio + d.Classification)
.join(
// + HANDLE ENTER SELECTION
- enter => enter,
- // + HANDLE UPDATE SELECTION
- update => update
- .call(sel => sel
- .transition()
- .duration(1000)
- // .delay(1500)
+ enter => enter
+ .append("rect")
.attr("class", "female-ratio")
.attr("year", d => d.Year)
.attr("x", d=> x(d.Year))
.attr("y", d=> y(d.f_ratio))
+ .call(sel => sel
+ .transition()
+ .duration(1000)
+ // .delay(1500)
+ .attr("x", d=> x(d.Year) - works(d.female))
+ .attr("y", d=> y(d.f_ratio) - works(d.female))
.attr("rx", 0)
.attr("ry", 0)
.attr("fill", colorScale(2) )
@@ -380,13 +425,30 @@ svg
.attr("ry", d=> works(d.female)* 2)
.attr("height", d=> works(d.female)*2)
.attr("width", d=> works(d.female)*2)),
+ // + HANDLE UPDATE SELECTION
+ update => update
+ .call(sel => sel
+ // .attr("rx", 0)
+ // .attr("ry", 0)
+ .transition()
+ .duration(1000)
+ .attr("x", d=> x(d.Year) - works(d.female))
+ .attr("y", d=> y(d.f_ratio) - works(d.female))
+ .attr("fill", colorScale(2) )
+ .attr('fill-opacity', "0.5")
+ .attr("rx", d=> works(d.female)* 2)
+ .attr("ry", d=> works(d.female)* 2)
+ .attr("height", d=> works(d.female)*2)
+ .attr("width", d=> works(d.female)*2)),
// + HANDLE EXIT SELECTION
exit => exit
.call(sel => sel
+ .attr("rx", d=> works(d.female)* 2)
+ .attr("ry", d=> works(d.female)* 2)
.transition()
.duration(1000)
- .attr("rx", 0)
- .attr("ry", 0)
+ .attr("height", 0)
+ .attr("width", 0)
.remove()),
)
.on("mouseleave", mouseleave )
@@ -400,9 +462,24 @@ svg
// + HANDLE ENTER SELECTION
enter => enter
.append("rect")
-
- .call(sel => sel
- ),
+ .attr("class", "male-ratio")
+ .attr("year", d => d.Year)
+ .attr("x", d=> x(d.Year) - works(d.male))
+ .attr("y", d=> y(d.m_ratio) - works(d.male))
+ .call(sel => sel
+ .transition()
+ .duration(1000)
+ // .delay(1500)
+ .attr("x", d=> x(d.Year) - works(d.male))
+ .attr("y", d=> y(d.m_ratio) - works(d.male))
+ .attr("rx", 0)
+ .attr("ry", 0)
+ .attr("fill", colorScale(1) )
+ .attr('fill-opacity', "0.5")
+ .attr("rx", d=> works(d.male)* 2)
+ .attr("ry", d=> works(d.male)* 2)
+ .attr("height", d=> works(d.male)*2)
+ .attr("width", d=> works(d.male)*2)),
// + HANDLE UPDATE SELECTION
update => update
.call(sel => sel
@@ -412,8 +489,8 @@ svg
.attr("class", "male-ratio")
.delay((d,i) => {return i*delaySet})
.attr("year", d => d.Year)
- .attr("x", d=> x(d.Year))
- .attr("y", d=> y(d.m_ratio))
+ .attr("x", d=> x(d.Year) - works(d.male))
+ .attr("y", d=> y(d.m_ratio) - works(d.male))
.attr("fill", colorScale(1) )
.attr('fill-opacity', "0.5")
.attr("rx", d=> works(d.male)*2)
@@ -423,11 +500,13 @@ svg
// + HANDLE EXIT SELECTION
exit => exit
- .call(sel => sel
- .transition()
- .duration(1000)
- .attr("rx", 0)
- .attr("ry", 0)
+ .call(sel => sel
+ .attr("rx", d=> works(d.male)* 2)
+ .attr("ry", d=> works(d.male)* 2)
+ .transition()
+ .duration(1000)
+ .attr("height", 0)
+ .attr("width", 0)
.remove()),
)
.on("mouseleave", mouseleave )
@@ -436,7 +515,10 @@ svg
function bars() {
- mouseHover = "";
+ filteredData = state.data
+ .filter(d => d.Classification === state.selectedClassification)
+ console.log(filteredData, (width / filteredData.length - 3))
+ state.selectedChart = "Bars";
d3.select('#init-y-axis')
// .transition()
@@ -561,19 +643,29 @@ function bars() {
enter => enter
.append("rect")
.attr("class", "male-ratio")
- .attr("id", d => `${d.Year}-${d.female}-${d.f_ratio}-${d.Classification}`)
+ .attr("id", d => `${d.Year}-${d.male}-${d.m_ratio}-${d.Classification}`)
.attr("year", d => d.Year)
- .call(sel => sel),
+ .attr("x", d=> x(d.Year))
+ .attr("y", d => yM(0))
+ .call(sel => sel
+ .transition()
+ .duration(1000)
+ .attr("fill", d3.schemeSet2[1])
+ .attr("x", d=> x(d.Year))
+ .attr("width", 8)
+ .attr('fill-opacity', "1")
+ // .delay((d,i) => {return i*delaySet})
+ .attr("y", d => yM(d.male))
+ .attr("height", d => yM(0) - yM(d.male))
+ .attr("rx", 0)
+ .attr("ry", 0)),
update => update
.call(sel => sel
.transition()
.duration(1000)
.attr("fill", d3.schemeSet2[1])
.attr("x", d=> x(d.Year))
- // .attr("y", (height / 2))
- // .attr("rx", 0)
- // .attr("ry", 0)
- .attr("width", (width / filteredData.length) -3)
+ .attr("width", 8)
.attr('fill-opacity', "1")
.delay((d,i) => {return i*delaySet})
.attr("y", d => yM(d.male))
@@ -587,7 +679,7 @@ function bars() {
.transition()
.duration(1000)
.attr("width", 0)
- .attr("height", 0)
+ // .attr("height", d=> yM(0))
// .delay(150)
// .attr("x", (width / 2)-25)
// .attr("height", 0)
@@ -605,23 +697,27 @@ svg // female
.attr("class", "female-ratio")
.attr("id", d => `${d.Year}-${d.female}-${d.f_ratio}-${d.Classification}`)
.attr("year", d => d.Year)
- .attr("fill", d3.schemeSet2[0])
- .attr("x", d => y(d.Year))
- .attr("y", (height / 2)+25)
- // .attr("height", d=> yM(d.female))
- .call(sel => sel
+ .attr("x", d=> x(d.Year))
+ .attr("y", d => yF(0))
+ .call(sel => sel
.transition()
.duration(1000)
- // .attr("width", (width / filteredData.length) -3)
- // .attr("width", width / filteredData.length)
-
- .attr("width", width / filteredData.length - 3)
+ .attr("fill", d3.schemeSet2[0])
+ .attr("x", d=> x(d.Year))
+ .attr("width", 8)
.attr('fill-opacity', "1")
- .attr("y", (height / 2)+25)
- .attr("height", d => yF(d.female))
- // .attr("rx", 0)
- // .attr("ry", 0)
- ),
+ // .delay((d,i) => {return i*delaySet})
+ .attr("y", d => yF(0))
+ .attr("height", d => yF(d.female)-(height/2))
+ .attr("rx", 0)
+ .attr("ry", 0)),
+ // .call(sel => sel
+ // .transition()
+ // .duration(1000)
+ // .attr("width", 8)
+ // .attr('fill-opacity', "1")
+ // .attr("y", (height / 2)+25)
+ // ),
update => update
.call(sel => sel
.transition()
@@ -629,7 +725,7 @@ svg // female
.delay((d,i) => {return i*delaySet})
.attr("y", d => yF(0))
.attr("height", d => yF(d.female)-(height/2))
- .attr("width", width / filteredData.length - 3)
+ .attr("width", 8)
.attr('fill-opacity', "1")
.attr("rx", 0)
.attr("ry", 0)
diff --git a/moma/buttons.html b/moma/buttons.html
index f623eff..ae92af5 100644
--- a/moma/buttons.html
+++ b/moma/buttons.html
@@ -24,16 +24,46 @@ MoMA Collecting Gender Disparity
broken out by the genders identified in the MoMA data. The size of the bubble represents how many artists of a given
gender were collected that year.
Highlight years where female artists outnumber male
+