Skip to content

Instantly share code, notes, and snippets.

View chemok78's full-sized avatar

Jay Mok chemok78

  • Hong Kong & The Netherlands
View GitHub Profile
@chemok78
chemok78 / app.js
Created February 15, 2017 07:47
Kickstarter, Movies and Videogames Sales D3 Treemap
//set dimensions of div container, svg and chart area(g element)
var margin = {
top: 20,
right: 20,
bottom: 80,
left: 20
};
//width of the chart, within SVG element
var w = 1100 - margin.left - margin.right;
@chemok78
chemok78 / app.js
Created February 6, 2017 04:43
World's Meteorites History D3 JS Bubble Map
//set margins for div container, SVG and chart area(g element)
var margin = {top: 20, right: 20, bottom: 20, left: 20};
//width of the chart, within SVG element
var w = 1100 - margin.left - margin.right;
//height of the chart, within SVG element
var h = 900 - margin.top - margin.bottom;
//Create SVG element and append to #chart div container
@chemok78
chemok78 / app.js
Created February 2, 2017 04:43
Force Directed Graph D3 JS - National Contiguity
var url = "https://raw.githubusercontent.com/DealPete/forceDirected/master/countries.json";
d3.json(url, function(json){
var data = json;
//Set dimensions of div container, SVG and chart area(g element)
var margin = {top: 40, right: 40, bottom: 40, left: 40};
//Width of the visualization area
@chemok78
chemok78 / app.js
Created January 26, 2017 10:04
Heatmap D3 JS - Monthly Global Land-Surface Temperature
var url = "https://raw.githubusercontent.com/FreeCodeCamp/ProjectReferenceData/master/global-temperature.json"
d3.json(url, function(json){
//load data from API and save in variables
var data = json.monthlyVariance;
var baseTemp = json.baseTemperature;
//global variable for the months to be accessed like months[i]
var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
@chemok78
chemok78 / app.js
Created January 25, 2017 03:44
D3 JS Scatterplot Graph Fastest Times Ever Up Alpe d'Huez
var url = "https://raw.githubusercontent.com/FreeCodeCamp/ProjectReferenceData/master/cyclist-data.json";
d3.json(url, function (json) {
var data = json;
//set dimensions of SVG container and chart area
var margin = {top: 60, right: 120, bottom: 80, left: 80};
//inner width for the chart, within SVG element
var w = 1000 - margin.left - margin.right;
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Roboto+Slab" rel="stylesheet">
</head>
<body>
@chemok78
chemok78 / app.js
Created December 28, 2016 04:26
React JS Leaderboard
var TableHeader = React.createClass({
render: function() {
return (
<thead>
<tr>
<th className="text-center">#</th>
<th className="text-center">Profile Pic</th>
<th className="text-center">Camper Name</th>
@chemok78
chemok78 / app.js
Created December 28, 2016 04:25
React JS Online Recipe Box
Storage.prototype.setObj = function(key,obj){
//Extend local storage prototype so we can store objects
return this.setItem(key, JSON.stringify(obj));
};
Storage.prototype.getObj = function(key){
return JSON.parse(this.getItem(key));
@chemok78
chemok78 / app.js
Created December 28, 2016 04:23
React JS Conway Game of Life
var Button = ReactBootstrap.Button;
var ButtonToolbar = ReactBootstrap.ButtonToolbar;
var App = React.createClass({
//function to generate board and set initial state
createBoard: function(width,height){
//function to create an array with board configuration
var array = [];