Skip to content

Instantly share code, notes, and snippets.

View timelyportfolio's full-sized avatar

timelyportfolio timelyportfolio

View GitHub Profile
@timelyportfolio
timelyportfolio / README.md
Last active August 29, 2015 14:17 — forked from wmleler/.block
@timelyportfolio
timelyportfolio / shinyApp.R
Last active August 29, 2015 14:17
forked from @rich-iannone dogs example
# Obtain 'dogs.csv'
# Created by Alex Bresler, available at:
# https://github.com/abresler/abresler.github.io/blob/master/blog/2015/february/exploring_agility_show/data/dogs.csv
dat_url <- "http://asbcllc.com/blog/2015/february/exploring_agility_show/data/dogs.csv"
dogs <- read.csv(dat_url, header = TRUE, stringsAsFactors = FALSE)
library(shiny)
# Install the latest DiagrammeR package from GitHub
# devtools::install_github("rich-iannone/DiagrammeR")
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="http://d3js.org/d3.v3.min.js"></script>
<style>
body {
font: 10px sans-serif;
}
#main {
/**
* Copyright (c) 2014, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#Run hclust
hc <- hclust(dist(USArrests[1:40,]), "ave")
#Function for extracting nodes and links
extractGraph<-function(hc){
n<-length(hc$order)
m<-hc$merge
links<-data.frame(source=as.numeric(), target=as.numeric(), value=as.numeric())
@timelyportfolio
timelyportfolio / README.md
Last active August 29, 2015 14:08 — forked from mbostock/.block
Yield Curve Animation with a d3.js brush as slider

Forked from Mike Bostock's brush as slider example, I use the brush/slider to drive an interactive exploration of the US Yield Curve. I think this is a much more helpful way of showing the data than the animated GIF from Treasury yield curve from the Volcker era through Greenspan, Bernanke, and Yellen.

Original Readme.md

By customizing the display of D3'��s [brush component](https://github.com/mbostock/d3/wiki/SVG-Controls), you can make a single-handle slider. Or, by using [custom resize handles](/mbostock/4349545), you can make a two-handled slider.
!function(){
var bP={};
var b=30, bb=150, height=600, buffMargin=1, minHeight=14;
var c1=[-130, 40], c2=[-50, 100], c3=[-10, 140]; //Column positions of labels.
var colors =["#3366CC", "#DC3912", "#FF9900","#109618", "#990099", "#0099C6"];
bP.partData = function(data,p){
var sData={};
sData.keys=[
@timelyportfolio
timelyportfolio / README.md
Last active April 1, 2024 12:45 — forked from mbostock/.block
demo programmatic control of a d3 brush

Programmatically Control a d3 brush

Forked from Mike Bostock's focus+context zoom gist to demonstrate how we can drive a d3 brush with code.

anybody know how to brush with code in #d3js?

— klr (@timelyportfolio) September 10, 2014
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

So I found this discussion, but I could not find an example demonstrating the steps proposed by Athan Reines.

For auto-redraw such that the focus of a 1D brush matches the graphed domain, you need to do as follows:

This example pulls together various examples of work with trees in D3.js.

The panning functionality can certainly be improved in my opinion and I would be thrilled to see better solutions contributed.

One can do all manner of housekeeping or server related calls on the drop event to manage a remote tree dataset for example.

Dragging can be performed on any node other than root (flare). Dropping can be done on any node.

Panning can either be done by dragging an empty part of the SVG around or dragging a node towards an edge.

@timelyportfolio
timelyportfolio / anal.r
Last active August 29, 2015 14:02 — forked from michalskop/anal.r
#setwd('~/uhk/dev/ar_ondrej_plachy/institution/')
data = read.table('data.tsv',sep="\t",header=TRUE)
data$time = data$year - 1983
data$random1 = rnorm(336, mean=0, sd=0.01)
data$random2 = rnorm(336, mean=0, sd=0.01)
attach(data)
fbalm2 =
ifelse(balance_of_parties_mandates<= 0.25, '0.0-0.25',
ifelse(balance_of_parties_mandates <= 0.5, '0.25-0.5',