Skip to content

Daily progress

RobinFrugte97 edited this page Nov 15, 2019 · 17 revisions

4-11-19

Today I started off with concepting. The geolocations of all the museum objects are being published very soon, so I'm thinking about using them in my visualisation. I had a couple of idea's I liked, but the museum objects didn't really allow me to continue with those. I had some difficulties with coming up with an idea that I liked and one that I could make work with the museum data available.

We had a lecture from Laurens about Strings and Arrays and how to edit them, using array functions like slice, split and join.

Towards the end of the day I thought of doing something with all the prints the museum has in their collection. There is a all sorts of prints in the collection, from different dates and parts of the world. I want to show on a spatial charts where in the world these prints come from.

I have an interactive idea;

  • Clicking on a region with prints allows you to see them all and have them sorted by for example date, size or material.

5-11-19

Today I started off with sketching my concept in order to later pitch it to Richard for some feedback. We had a lecture about D3 and gathering data. We can start using D3, although I'm still focused on getting my concept right.

I started writing the SPARQL query that I need for all prints. I'm still waiting on the endpoints to update so I can retrieve the coordinates as in longitude and latitude.

I started to practise cleaning some data with JavaScript. The data I'm using is a row with students' hobby's as gathered with a previous survey. This is how the data looks at the moment, before any cleaning is done:

Dirty survey data Voetbal, Gamen, Design, Schoenen verzamelen Voetbal; Gamen; Bioscoop;

Series kijken; Sporten; Lezen pianospelen; films kijken; simsen; voetballen; tennissen; sporten Honkbal; Auto's; Varen; zwemmen; pianospelen; dansen Muziek maken; muziek produceren; uitgaan met vrienden Skien, surfen, kitesurfen, wielrennen voetbal, gezelligheid, kleding Muziek; Games; Tekenen; gamen(nintendo); lezen; wandelen;

Schilderen en winkelen netflix; festival; shoppen tennis Chillen Lopen Volleybal; graphic design; basketbal Reizen; zwemmen; muziek luisteren vormgeven; gamen; tafeltennis; bioscoop Graffiti, snowboarden; films kijken; koken; reizen Gamen; Lezen rollerskaten; snowboarden; tekenen; tv kijken; drankjes doen Gamen; relaxen; hockey; biertjedrinken Coderen; Tennis; Voetbalwedstrijden analyseren Tekenen, gamen, lezen, schrijven Fotografie; plantenverzorging; slapen; festivalbezoeken Chillen, sporten, uitgaan gamen; leven Gamen; Serie kijken; terrass pakken hockey; netflix; uitgaan voetballen, feesten Netflixen, vrienden meeten, reizen vliegvissen; programmeren; reizen; netflix; dansen; uit gaan; wandelen eten, bios pakken, muziek luisteren, dansen op festivals, rijden Fotografie; DJ Netflix, fitness Netflix; borrelen; slapen muziek; slapen; films; chillen Voetbal gamen; wandelen; fietsen door mooie gebieden; leuke dingen met vrienden; festival bezoeken; koffie drinken; veel planten verzamelen voetballen, boxen, tekenen, dansen, zingen Voetbal; Mountainbiking; Computer - hardware; Handel in technologie; Video - gamen; Meubel - restoraties; Sci - Fi boeken lezen; Japanse cultuur; Tekenen; muziek maken slapen, films kijken Gamen, afspreken met vrienden, uitgaan Wielrennen; Voetballen; Gitaarspelen Voetballen; netflixen: fifa Series kijken; Muziek luisteren; Afspreken met mensen; Festivallen bezoeken; Lekker eten gamen; netflix kijken; sporten Schilderen; computeren Sporten; computeren Tekenen; Serie's kijken; Drankje drinken Series kijken; Tekenen Films, muziek, games Fitness; Voetbal; Tennis; Uitgaan; Tekenen Muziek luisteren en zoeken Gamen Hockey Drummen; Gamen; Chillen Gamen, karten tekenen; voetballen Zingen; Gitaar spelen; Fotograferen Basketbal; uitgaan skateboarden, fotograferen, filmen, drummen Hobbies zijn voor de delusionals Gitaar spelen; gamen; waterpolo; wandelen; reizen Feesten; borrelen; netflixen; vakantie Motorrijden; Gamen Fitness, Dichten; blowen Games, tekenen, gitaar, muziek maken Films en series

I will spend some time in the next couple of days to clean this data.

Changes to the concept

I pitched my idea to Richard. I liked the idea, but he told me the data would be very one-sided. The majority of the prints originate from Japan. After the pitch I decided to change my concept to displaying all prints in Japan. In theory this will allow me to actually display the prints on a map, because I have more room now relatively speaking.

6-11-19

7-11-19

I started off today with my SPARQL query. I added the longitude and latitude of every entry to the query.

?place skos:exactMatch/wgs84:lat ?lat .
?place skos:exactMatch/wgs84:long ?long .
?place skos:exactMatch/gn:parentCountry ?land .

8-11-19

  • Cleaning data
  • Progress discussion

11-11-19

Introduction to D3. I learned about the enter update and exit pattern of D3. The essence is that you enter elements in your dom by filling up the data you have loaded in. You then update these elements with whatever you need to make your visualization. Lastly you exit, which can for example remove any not used elements. Exit lets you do things with the elements that don't have any data assigned to them.

We also did a d3 experiment. We had a limited amount of time to create a face in d3. This is my result:

<svg viewbox="0 0 1000 1000">
        <defs>
            <radialGradient id="myGradient">
                <stop offset="10%" stop-color="gold" />
                <stop offset="95%" stop-color="red" />
            </radialGradient>
        </defs>
        
        <!-- using my linear gradient -->
        <g>
            <circle cx="500" cy="250" r="120" fill="url('#myGradient')">
                <animate attributeName="r" values="150;175;150" dur="3s" repeatCount="indefinite" />
            </circle>
            <circle cx="450" cy="200" r="20" fill="black"></circle>
            <circle cx="550" cy="200" r="20" fill="black"></circle>
            <ellipse cx="500" cy="300" rx="40" ry="20" fill="black"></ellipse>
            <rect width="20" height="20" x="510" y="250" fill="white">
            </rect>
        </g>
</svg>

12-11-19

I started today by beginning work on my own app. The first thing I wanted to do is get a map of Japan in D3. I looked at examples of how to plot a chart with D3 with geolocations in mind. I created a test environment to play around with a couple of examples. I searched for a SVG file of the Japanese map. I implemented the map data locally. After I was statisfied with the result, I placed the test code inside my actual app code. I got it to work with together with the SPARQL query.

I rewrote some of my original fetch code to be more functional. I removed some variable await declarations and replaced them with a .then.

Next step

The next step is to render the geolocation points on the map from my SPARQL data. I added one static set of coordinates to see if they would work. They are rendered on the page, but as you can tell from the image they are not in the correct place.

13-11-19

I fixed the scaling on the chart so that it scales with the width and height of the container. It is also always centered.

function setChartPosition(topo) {
	let projection = d3.geoMercator().scale(150).center(d3.geoCentroid(topo))
		.translate([width / 2, height / 2]);
	let path = d3.geoPath().projection(projection);

	// using the path determine the bounds of the current map and use 
	// these to determine better values for the scale and translation
	let bounds = path.bounds(topo);
	let hscale = 150 * width / (bounds[1][0] - bounds[0][0]);
	let vscale = 150 * height / (bounds[1][1] - bounds[0][1]);
	let scale = (hscale < vscale) ? hscale : vscale;

	// new projection
	projection = d3.geoMercator().center(d3.geoCentroid(topo))
		.scale(scale).translate([width - (bounds[0][0] + bounds[1][0]) / 2,
		height - (bounds[0][1] + bounds[1][1]) / 2]);
	path = path.projection(projection);
	return [path, projection]
}

After fixing the map of Japan I got the geolocation test to correctly show on the Japanese map, by using the same formula to position the chart.

d3.select("svg").selectAll("circle")
  .data(data).enter()
  .append("circle")
  .attr("cx", function (d) { console.log(d); return setChartPosition(topo)[1](d)[0] })
  .attr("cy", function (d) { return setChartPosition(topo)[1](d)[1] })
  .attr("r", "8px")

For now the coordinates will be indicated with a simple circle, later this will be an image of the print.

The images are now working thanks to Kim.

d3.select("svg").selectAll("image")
			.data(data).enter()
			.append("image")
			.attr("xlink:href", data.printImage)
			.attr("x", function (d) { return projection([d.long, d.lat])[0] })
			.attr("y", function (d) { return projection([d.long, d.lat])[1] })
			.attr("width", "3em")
			.attr("height", "2em")
	})

This is the version I made myself, but it didn't work. For some reason the xlink:href attribute with the image source was not added to the image elements.

d3.select("svg").selectAll("images")
			.data(data).enter()
			.append("image")
			.attr("xlink:href", data => data.printImage)
			.attr("x", function (d) { return projection([d.long, d.lat])[0] })
			.attr("y", function (d) { return projection([d.long, d.lat])[1] })
			.attr("width", "3em")
			.attr("height", "2em")
	})

Thanks to Kim I managed to fix the issue. I select all images now instead of all image. The image source is wrapped in a function now and it works because the d3 attribute needs a callback function instead of one variable.

14-11-19

I decided to show all objects in Japan instead of just the prints. This allows me show more objects on the chart. I'm now able to change the subject of the objects in the visualisation by adjusting the subjects in the SPARQL query.

More functional

I spent the majority of the day making my application more functional. Yesterday I already seperated most of my code in functions that can be reused. In my main Javascript file there is a single function that builds the visualisation. The first function called by the main function fetchData, fetches the data and cleans it before returning it to the main function. After that, the cleaned data is given as a parameter to the drawVis function, which generates the chart with the images on it.

I also seperated some functions or function groups in modules. This allows for better reusablity, which is one of the main points of functional programming.

I made the cleanup code I wrote last week functional in the same manner, except for the modules.

Clone this wiki locally