Skip to content

Instantly share code, notes, and snippets.

View eesur's full-sized avatar

Sundar Singh eesur

View GitHub Profile
@eesur
eesur / .block
Last active January 29, 2018 13:01
d3js | enclosing diagram | circle pack
license: mit
height: 500
border: no
@eesur
eesur / .block
Last active December 19, 2017 16:20
d3js | box and whiskers (boxplot)
license: mit
height: 500
border: no
@eesur
eesur / .block
Created December 12, 2017 18:36
d3 | radial force
license: mit
height: 500
border: no
@eesur
eesur / README.md
Last active October 23, 2019 21:51
d3 | time shown as percentage

using a waffle chart to show time in percentage. Updating every second and squares/percentage is rounded down to nearest integer

@eesur
eesur / .block
Last active October 23, 2019 21:51
d3 | modulo operation to create a grid
license: mit
height: 500
border: no
@eesur
eesur / .block
Last active December 4, 2017 22:19
d3 | bar chart with just pipe character
license: mit
height: 500
border: no
@eesur
eesur / .script-compiled.js
Last active November 27, 2017 14:31
d3 | Redux action
// #1a1a1a : #a634a0
(function () {
var d3 = window.d3
var Redux = window.Redux
// Create a Redux store holding the state of the app
// Its API is { subscribe, dispatch, getState }.
var store = Redux.createStore(active)
var initialstate = {
fill: '#1a1a1a',
@eesur
eesur / README.md
Last active October 5, 2017 11:06
d3 | width of div container

simple example showing how to get the width of a div and use it's value/number

var containerWidth = +d3.select('.some-div').style('width').slice(0, -2)

it's an easy way to size/re-size drawings based on the containing div:

selection.append('svg')
 .attr('width', containerWidth)
@eesur
eesur / .script-compiled.js
Last active November 26, 2017 19:36
d3 | reusable single value donut chart
var d3 = window.d3
// hook on with a temp namespace
d3.eesur = {}
d3.eesur.singleValueDonut = function createDonut () {
// getter/setters
var height = null
var width = null
var innnerRadius = 45
var outerRadius = 90
@eesur
eesur / .script-compiled.js
Created August 25, 2017 09:58
d3 | simple pagination (next/prev)
(function () {
var d3 = window.d3
// have a reference to the containing element
var dom = d3.select('.js-vis-wrap')
// create some dummy data
/* const data = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 ...] */
var data = d3.range(18).map(function (n) { return n * 10; })
// have a max number of items to display
var maxDisplay = 10
// track if the pagination is clicked