Skip to content

Instantly share code, notes, and snippets.

@nachocab
Created May 19, 2013 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nachocab/5607579 to your computer and use it in GitHub Desktop.
Save nachocab/5607579 to your computer and use it in GitHub Desktop.
crossfilter racetrack
{"description":"crossfilter racetrack","endpoint":"","display":"svg","public":true,"require":[{"name":"xf filter function","url":"http://enjalot.github.com/crossfilter/crossfilter.min.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"cars.csv":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"conf.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.coffee":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"tab":"edit","display_percent":0.46399999999999975}
@append_main = (opts = {}) ->
opts.element ?= "svg:svg"
opts.selector ?= "body"
opts.background ?= "#fff"
opts.width ?= 200
opts.height ?= 200
opts.margin ?= 10
main = d3.select(opts.selector)
.append(opts.element)
.attr('width', opts.width)
.attr('height', opts.height)
.style('background', opts.background)
.style('margin', opts.margin)
if (opts.id)
main.attr("id", opts.id)
if (opts.class)
main.attr("class", opts.class)
main.width = opts.width
main.height = opts.height
main
@append_plot = (opts = {}) ->
opts.margin ?=
top: 20
right: 150
bottom: 30
left: 50
opts.width ?= 400
opts.height ?= 400
opts.axis_padding ?= 20
opts.background ?= "#fff"
opts.width = opts.width - opts.margin.left - opts.margin.right
opts.height = opts.height - opts.margin.top - opts.margin.bottom
# TODO: refactor opts_for_main so you don't have to duplicate properties
plot = append_main(
background: opts.background
id: opts.id
width: opts.width + opts.margin.left + opts.margin.right
height: opts.height + opts.margin.top + opts.margin.bottom
margin: 20
)
plot = plot.append("svg:g")
.attr("transform", "translate(#{opts.margin.left},#{opts.margin.top})")
plot.scales = get_scales(opts.width, opts.height)
plot.margin = opts.margin
plot.width = opts.width
plot.height = opts.height
plot
plot = append_plot({background:"lightblue"})
.marker {
fill:#49BDFF;
fill-opacity: 0.33;
stroke: none
}
.userbar {
fill: #FFFFFF;
fill-opacity: 0.74681
}
.count {
fill: #63ACD5;
fill-opacity: 0.736;
stroke: #fff;
stroke-width: 1
shape-rendering: crispEdges;
}
text {
font-size: 0.4em;
font-family: Roboto;
font-weight: 300;
}
.axis path,
.axis line {
fill: none;
stroke: #919191;
shape-rendering: crispEdges;
}
#panel #file-list {overflow-x: hidden;}
//.x.axis path {
// display: none;
//}
.background{
visibility: visible !important;
fill: #FFFFFF;
}
.extent {
visibility: visible !important;
fill: #84D8F8;
}
.resize rect {
visibility: visible !important;
fill: #888888;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment