Skip to content

Instantly share code, notes, and snippets.

View git-ashish's full-sized avatar
🏠
Freelancing – Open to exciting opportunities

Ashish Singh git-ashish

🏠
Freelancing – Open to exciting opportunities
View GitHub Profile
@git-ashish
git-ashish / dnd.js
Created November 5, 2013 15:09 — forked from johan/dnd.js
// http://www.html5rocks.com/en/tutorials/file/dndfiles/
d3.select('svg')
.on('dragover', handleDragOver)
.on('drop', handleFileSelect)
;
function handleFileSelect() {
var event = d3.event
, files = event.dataTransfer.files // FileList object
, about = []
@git-ashish
git-ashish / README.md
Created November 5, 2013 15:09 — forked from mbostock/.block
@git-ashish
git-ashish / dnd.js
Created November 5, 2013 15:12 — forked from johan/dnd.js
// http://www.html5rocks.com/en/tutorials/file/dndfiles/
d3.select('svg')
.on('dragover', handleDragOver)
.on('drop', handleFileSelect)
;
function handleFileSelect() {
var event = d3.event
, files = event.dataTransfer.files // FileList object
, about = []
@git-ashish
git-ashish / jsdatediff1.js
Last active December 31, 2015 01:48
Find difference between 2 dates in JavaScript using format mm/dd/yyyy
var start_date = new Date('12/01/2013'),
end_date = new Date(),
one_day_in_milliseconds = 1000*60*60*24,
date_diff = Math.floor( ( end_date.getTime() - start_date.getTime() )/one_day_in_milliseconds ) ;
console.log("Result 1 - Date difference between ",end_date, " & ",start_date, " - ", date_diff);
var s_date = new Date('2013-12-01'),
date_diff_2 = Math.floor( ( end_date.getTime() - s_date.getTime() )/one_day_in_milliseconds ) ;
@git-ashish
git-ashish / jsdatediff2.js
Last active December 31, 2015 01:48
Find difference between 2 dates in JavaScript using format yyyy-mm-dd
function getNewDate(dateString){
var date = dateString ? new Date(dateString) : new Date(),
timezoneOffset = date.getTimezoneOffset();
return new Date( date.getTime() + timezoneOffset*60*1000*(dateString?1:0) );
}
var start_date = getNewDate('2013-12-01'),
end_date = getNewDate(),

This example shows how it is possible to use a D3 sunburst visualization (partition layout) with data that describes sequences of events.

A good use case is to summarize navigation paths through a web site, as in the sample synthetic data file (visit_sequences.csv). The visualization makes it easy to understand visits that start directly on a product page (e.g. after landing there from a search engine), compared to visits where users arrive on the site's home page and navigate from there. Where a funnel lets you understand a single pre-selected path, this allows you to see all possible paths.

Features:

  • works with data that is in a CSV format (you don't need to pre-generate a hierarchical JSON file, unless your data file is very large)
  • interactive breadcrumb trail helps to emphasize the sequence, so that it is easy for a first-time user to understand what they are seeing
  • percentages are shown explicitly, to help overcome the distortion of the data that occurs wh
@git-ashish
git-ashish / bfs
Last active January 2, 2016 22:09
Breadth First Search
/**
* Breadth First Search to traverse through all data points
*
* Structure of json :
*
* { "name": "Alpha",
* "children": [
* {
* "name": "Beta",
* "children": [{

Faux-3d SVG globe using d3.geo.orthographic and a few radial gradients. Labels offset or hidden based on radians from current map center to enhance the effect.

Uncomment svg.append("g").attr("class","countries") for hover-able country outlines.

Building on this - experimenting with fake 3d svg arcs using two nested orthographic projections and cardinal line interpolation.

@git-ashish
git-ashish / energy.json
Created February 12, 2014 16:43
d3 Sankey Demo
{"nodes":[
{"name":"Agricultural 'waste'"},
{"name":"Bio-conversion"},
{"name":"Liquid"},
{"name":"Losses"},
{"name":"Solid"},
{"name":"Gas"},
{"name":"Biofuel imports"},
{"name":"Biomass imports"},