Skip to content

Instantly share code, notes, and snippets.

View amitkaps's full-sized avatar

Amit Kapoor amitkaps

View GitHub Profile
<!DOCTYPE html>
<script src="../lib/d3.min.js"></script>
<svg id="chart"></svg>
<script>
var data = [5, 25, 15, 20, 10];
<!DOCTYPE html>
<script src="../lib/d3.min.js"></script>
<div id="chart"></div>
<script>
var data = [5, 25, 15, 20, 10];
d3.select("#chart")
<!DOCTYPE html>
<style>
#chart div {
background-color: brown;
height: 25px;
margin: 5px;
}
</style>
<!DOCTYPE html>
<canvas id="chart" width="250" height="200"></canvas>
<script>
var data = [5, 25, 15, 20, 10];
var canvas = document.getElementById("chart");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "brown";
for (i = 0; i < data.length; i++){
@amitkaps
amitkaps / Bar_svg.html
Last active October 6, 2015 03:53
Bar Chart - SVG
<!DOCTYPE html>
<svg class="chart" width="250" height="200" fill="brown" >
<rect x="0" y="0" width="50" height="25"></rect>
<rect x="0" y="30" width="250" height="25"></rect>
<rect x="0" y="60" width="150" height="25"></rect>
<rect x="0" y="90" width="200" height="25"></rect>
<rect x="0" y="120" width="100" height="25"></rect>
</svg>
@amitkaps
amitkaps / Bar_html.html
Last active October 5, 2015 20:41
Bar Chart - HTML
<!DOCTYPE html>
<style>
#chart div {
background-color: brown;
height: 25px;
margin: 5px;
}
</style>
@amitkaps
amitkaps / rbokeh.R
Created September 10, 2015 05:15
Explore rbokeh library in R
library(dplyr)
library(ggplot2)
library(rbokeh)
########################
# Layering
########################
# Histogram & Density Plot - Price
ggplot(diamonds) + aes(price, y = ..density..) +
# Load the library
library(ggplot2)
library(ggmap)
# Create a dummy data frame of points
set.seed(500)
df <- round(data.frame(
lon = jitter(rep( 77.59, 50), amount = .3),
lat = jitter(rep( 12.97, 50), amount = .3)
), digits = 2)
## Scraper One
library(rvest)
url = "http://nuforc.org/webreports/ndxe201507.html"
pg <- html(url)
nodes <- html_nodes(pg, "table")
table <- html_table(nodes)
str(table)
View(table)
# Alternate pipe function
@amitkaps
amitkaps / Multi Variable Visualization
Created May 5, 2015 02:36
Moving up the ladder of multi variable visualisation (in R)
library(ggplot2)
?mpg
head(mpg)
str(mpg)
# Identify a scatter point
attach(mtcars)
plot(mpg, wt)
identify(x = mpg, y = wt, n = 3, label = row.names(mtcars))
detach(mtcars)