This example choropleth encodes road deaths in the Republic of Ireland in 2010. The data is taken from the Irish Road Safety Authority. Irish geoJSON data based on https://gist.github.com/2183412. Colours by Colorbrewer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log('Client-side code running'); | |
const button = document.getElementById('myButton'); | |
button.addEventListener('click', function(e) { | |
console.log('button was clicked'); | |
fetch('/clicked', {method: 'POST'}) | |
.then(function(response) { | |
if(response.ok) { | |
console.log('click was recorded'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---------------------------- | |
// Parent class (or superclass) | |
// ---------------------------- | |
function Circle(x = 50, y = 50, r = 100, col = '#f00') { | |
this.x = x; | |
this.y = y; | |
this.r = r; | |
this.col = col; | |
this.vx = random(-5,5); | |
this.vy = random(-5,5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
import axios from "axios"; | |
class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { users: [], searchTerm: '', alphabetical: 'az' }; | |
this.handleChange = this.handleChange.bind(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
class UserProfiles extends React.Component { | |
constructor(){ | |
super(); | |
this.state = { | |
name: {title: '', first: '', last: ''}, | |
image: '' | |
}; | |
// fix the this value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let myCircle; | |
function setup() { | |
createCanvas(400, 400); | |
background(0); | |
// retrieve the x, y coords from the DB | |
fetch('/circle', {method: 'GET'}) | |
.then(function(response) { | |
if(response.ok) return response.json(); | |
throw new Error('Request failed.'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const MongoClient = require('mongodb').MongoClient; | |
const server = express(); | |
const port = 3000; | |
server.get('/', (req, res) => res.send('Hello World!')); | |
server.get('/api/users', (req, res) => { | |
MongoClient.connect('mongodb://localhost:27017/REACTCA2', function (err, client) { | |
if (err) throw err |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---------------------------- | |
// Parent class (or superclass) | |
// ---------------------------- | |
class Circle { | |
constructor(x = 50, y = 50, r = 100, col = '#f00') { | |
this.x = x; | |
this.y = y; | |
this.r = r; | |
this.col = col; | |
this.vx = random(-5,5); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
class UserProfiles extends React.Component { | |
constructor(){ | |
super(); | |
this.state = { | |
users: [] | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
class SignUp extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
newsLetter: true, | |
email: '' | |
}; |
NewerOlder