Published
Edited
Feb 6, 2022
Insert cell
# Week4 Reflection
Insert cell
<p>I use the same data from homework1 to show what I learn this week.</p>
Insert cell
dataCsv = `app_name,downloads,average_rating,thirty_day_keep
Cardify,105707,4.95,94.73
Duobam,481340,4.88,84.09
Trippledex,81464,4.67,94.98
Veribet,205046,4.6,80.86
Span,533218,4.66,91.42
Greenlam,691552,4.96,70.98
DoubleyDo,990365,4.75,85.11
Prodder,170564,4.85,75.11
Cookley,498787,4.87,82.39
Flexidy,570023,4.88,72.86
Ronstring,709601,4.98,81.31
Cardonia,74369,4.7,81.62
Bitwolf,375372,4.96,85.44
Sonair,941836,4.78,72.88
Quo Lux,469201,4.99,71.52
Solarbreeze,276653,4.78,79.35
Transcof,654739,4.57,98.19
Veribot,867917,4.89,72.39
Zontrax,760672,4.81,82.64
Stim,750826,4.86,80.51`
Insert cell
data = d3.csvParse(dataCsv)
Insert cell
d3 = require("d3@7")
Insert cell
<h1>Sample 1</h1>
Insert cell
makeChart4 = (dataset) => {
const yGap = 24;
const w = 1000;
const h = dataset.length * yGap;
const chart4Svg = d3.create("svg")
.attr('width', w)
.attr('height', h);

const xScale = d3
.scaleLinear()
.domain([0, d3.max(dataset, (d) => d.downloads )])
.rangeRound([0, w - 100]);
const yScale = d3
.scaleLinear()
.domain([100, 0])
.rangeRound([40, h - 40]);
const rScale = d3
.scaleSqrt()
.domain([d3.min(dataset, (d) => d.thirty_day_keep), d3.max(dataset, (d) => d.thirty_day_keep)])
.rangeRound([1, 10]);

// FILL IN HERE, and observe changes below

chart4Svg
.selectAll("circle")
.data(dataset)
.join("circle")
.attr("fill","#a3a4a6")
.attr("cx", (d) => xScale(d.downloads))
.attr("cy",(d) => yScale(d.thirty_day_keep))
.attr("r", (d) => rScale(d.thirty_day_keep));
chart4Svg
.selectAll("text")
.data(dataset)
.join("text")
.text(d => d.app_name)
.attr("x", (d) => xScale(d.downloads))
.attr("y",(d) => yScale(d.thirty_day_keep))
.attr("font-family", "Arial")
.attr("fill","#f8e561");
chart4Svg
.append("g")
.attr("class", "axis")
.attr("transform", `translate(40, ${h - 20})`)
.call(d3.axisBottom(xScale));
chart4Svg
.append("g")
.attr("class", "axis")
.attr("transform", `translate(40,20)`)
.call(d3.axisLeft(yScale).tickSize(0).tickFormat(d => d + "%"));
return chart4Svg.node();
}
Insert cell
makeChart4(data)
Insert cell
<p>This is the first version of the table. I have written the Domain parameter setting range as 0-100. this allows the user to see the complete data from 0 to 100. But in fact, the user can't see all the data because the distance from point to point is too close. The points themselves have size and the distance between them is too narrow. This results in no way for the user to see what the dots represent.
Insert cell
<h1>Sample2<h1>
Insert cell
makeChart5 = (dataset) => {
const yGap = 50;
const w = 1000;
const h = dataset.length * yGap;
const chart5Svg = d3.create("svg")
.attr('width', w)
.attr('height', h);

const xScale = d3
.scaleLinear()
.domain([0, d3.max(dataset, (d) => d.downloads )])
.rangeRound([0, w - 100]);
const yScale = d3
.scaleLinear()
.domain([100, 70])
.rangeRound([40, h - 40]);
const rScale = d3
.scaleSqrt()
.domain([d3.min(dataset, (d) => d.thirty_day_keep), d3.max(dataset, (d) => d.thirty_day_keep)])
.rangeRound([1, 10]);

// FILL IN HERE, and observe changes below

chart5Svg
.selectAll("circle")
.data(dataset)
.join("circle")
.attr("fill","#a3a4a6")
.attr("cx", (d) => xScale(d.downloads))
.attr("cy",(d) => yScale(d.thirty_day_keep))
.attr("r", (d) => rScale(d.thirty_day_keep));
chart5Svg
.selectAll("text")
.data(dataset)
.join("text")
.text(d => d.app_name)
.attr("x", (d) => xScale(d.downloads))
.attr("y",(d) => yScale(d.thirty_day_keep))
.attr("font-family", "Arial")
.attr("fill","#f8e561");
chart5Svg
.append("g")
.attr("class", "axis")
.attr("transform", `translate(40, ${h - 20})`)
.call(d3.axisBottom(xScale));
chart5Svg
.append("g")
.attr("class", "axis")
.attr("transform", `translate(40,20)`)
.call(d3.axisLeft(yScale).tickSize(0).tickFormat(d => d + "%"));
return chart5Svg.node();
}
Insert cell
makeChart5(data)
Insert cell
<p>In this version of the chart I only show the points between 70% and 100%, which in fact covers all the points. Because I have narrowed the display, there is more space available for each point. This makes the points less dense. The user can easily read this chart.</p>
<p>Since no points would appear below 70%, I considered this to be useless space, so I omitted them.</p>
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