Skip to content

Commit

Permalink
Merge pull request #90 from Birkbeck2/changes-in-class
Browse files Browse the repository at this point in the history
Changes to files, added JSON vs JS Object table
  • Loading branch information
HelenaHW committed Feb 24, 2024
2 parents b43d2ce + 7be11d6 commit 7b1ac78
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lectures/visualising-data-js-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

*[Image](https://www.freepik.com/free-vector/business-performance-analysis-with-graphs_3425212.htm) by rawpixel.com on Freepik*

## JSON vs JavaScript object

![JSON vs JavaScript object](./images/table.png)

## JSON.parse()

Expand Down
1 change: 1 addition & 0 deletions public/sandbox/VDWP4_VisualisingDataWithJS/JSONparse.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// #region snippet
const text = '{"name":"John", "birth":"1986-12-14", "city":"New York"}';
const obj = JSON.parse(text);
//console.log(obj);
obj.birth = new Date(obj.birth);

document.getElementById("demo").innerHTML = obj.name + ", " + obj.birth;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

const obj = {name: "John", age: 30, city: "New York"};
const myJSON = JSON.stringify(obj);
console.log(obj);

document.getElementById("demo").innerHTML = "Here is my JSON: " + myJSON;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fetch('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.geojso
let y = geoArray[i].geometry.coordinates[1];
console.log(y);
let location = geoArray[i].properties.place;
//cx.resetTransform();
cx.translate(180, 90);
cx.beginPath(); // method of Canvas 2D API starts a new path
cx.arc(x, y, magnitude, 0, 2 * Math.PI); // arc(x, y, radius, startAngle, endAngle)
Expand Down

0 comments on commit 7b1ac78

Please sign in to comment.