Skip to content

Instantly share code, notes, and snippets.

View robert-moore's full-sized avatar

Rob Moore robert-moore

View GitHub Profile
@robert-moore
robert-moore / .block
Last active February 17, 2018 00:18
D3 HTML Selections
license: mit
@robert-moore
robert-moore / .block
Last active February 17, 2018 00:07
Div Bar Chart
license: mit
@robert-moore
robert-moore / .block
Last active February 16, 2018 05:10
IMDB vs Rotten Tomatoes
license: mit
@robert-moore
robert-moore / .block
Last active February 16, 2018 05:07
fresh block
license: mit
@robert-moore
robert-moore / index.html
Created February 16, 2018 04:46
fresh block
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
@robert-moore
robert-moore / tooltips.js
Created January 27, 2018 21:28
D3 Tooltips
// generates innerHTML for tooltip based on title and a map of key:value pairs
export function keyValueTitleTooltip(tooltip, title, map) {
tooltip.classed("key-value-tooltip", true).html("")
if (title)
tooltip
.append("p")
.attr("class", "title")
.text(title)
tooltip
.selectAll("p.value")
@robert-moore
robert-moore / dropshadow.js
Created January 18, 2018 22:09
SVG Drop Shadow
export function addDropShadowDef(defsSelection, id, size, opacity) {
const filter = defsSelection.append("filter")
.attr("id", id)
.attr("height", "130%")
filter.append("feGaussianBlur")
.attr("in", "SourceAlpha")
.attr("stdDeviation", size * 1.5) // stdDeviation is how much to blur
filter.append("feOffset")
.attr("dx", size)
@robert-moore
robert-moore / .block
Created November 7, 2017 23:26
Semantic Cluster Positioning - d3.carto
license: mit
@robert-moore
robert-moore / .block
Created October 23, 2017 20:54
Positive-Negative Bar Chart
license: gpl-3.0
@robert-moore
robert-moore / handlers.js
Created August 4, 2017 20:45
Google Map Autocomplete to FIPS
function initAutocomplete() {
autocomplete = new google.maps.places.Autocomplete(
(document.getElementById('autocomplete')),
{types: ['geocode']});
}
function geolocate() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var geolocation = {