Skip to content

Instantly share code, notes, and snippets.

@rickdg
Created May 15, 2015 22:55
Show Gist options
  • Save rickdg/607760f09ce0f5990199 to your computer and use it in GitHub Desktop.
Save rickdg/607760f09ce0f5990199 to your computer and use it in GitHub Desktop.
Another Inlet
{"description":"Another Inlet","endpoint":"","display":"div","public":true,"require":[{"name":"crossfilter","url":"https://cdnjs.cloudflare.com/ajax/libs/crossfilter/1.3.11/crossfilter.min.js"},{"name":"crossfilter","url":"https://raw.github.com/jasondavies/crossfilter/filter-custom/crossfilter.min.js"},{"name":"crossfilter","url":"https://cdnjs.cloudflare.com/ajax/libs/crossfilter/1.3.11/crossfilter.min.js"},{"name":"crossfilter2","url":"https://cdnjs.cloudflare.com/ajax/libs/crossfilter/1.3.11/crossfilter.min.js"}],"tab":"edit","display_percent":0.6915789473684211,"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,"fileconfigs":{"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"ajax-caching":true}
var data = [
{id: 1, tags:["svg", "d3"]},
{id: 2, tags:["processing", "canvas"]},
{id: 3, tags:["webgl", "canvas"]},
{id: 4, tags:["raphael", "svg", "d3", "dd"]}
];
var xf = crossfilter(data);
var tags = xf.dimension(function(d) { return d.tags });
var tag = "d3";
tags.filter(function(d) {
if(d.indexOf(tag) >= 0) return true;
return false;
})
var display = d3.select("#display");
display.append("br");
display.selectAll("span")
.data(tags.top(Infinity))
.enter()
.append("span")
.text(function(d) { return JSON.stringify(d) })
.append("br")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment