Skip to content

Instantly share code, notes, and snippets.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@NatasaPeic
NatasaPeic / .block
Created December 16, 2016 14:19 — forked from mbostock/.block
Stacked Bar Chart
license: gpl-3.0
@NatasaPeic
NatasaPeic / README.md
Created December 19, 2016 17:06 — forked from ZJONSSON/README.md
d3.legend example

d3.legend

d3.legend is a quick hack to add a legend to a d3 chart. Simply add a g and .call(d3.legend). Any elements that have a title set in the "data-legend" attribute will be included when d3.legend is called. Each title will appear only once (even when multiple items define the same data-legend) as the process uses a set based on a existing names, not an array of all items.

Color

By default the color in the legend will try to match the fill attribute or the stroke attribute of the relevant items. Color can be explicitly defined by attribute "data-legend-color"

Order

The order of items in the legend will be sorted using the top of the bounding box for each included item. The order can be explicitly defined by attribute "data-legend-pos"

@NatasaPeic
NatasaPeic / Responsive-Stacked-Horizontal-Bar-Chart-using-D3.js-and-BootstrapCSS
Created December 30, 2016 14:37
Responsive Stacked Horizontal Bar Chart using D3.js and Bootstrap CSS
# Responsive Stacked Horizontal Bar Chart using D3.js and Bootstrap CSS
It uses the following:
* D3.js v3
* Bootstrap CSS v3.3.5
It has the following features:
@NatasaPeic
NatasaPeic / README.md
Created February 13, 2017 16:07 — forked from eesur/README.md
Pre-loading using spin.js with d3

Example using spin.js during load of JSON data for a D3 chart

Showing the spinner/loader being triggered before the JSON callback, and stopped within the JSON callback (hence after the JSON data has been loaded):

// loader settings
var target = document.getElementById('#chart-id');

function init() {
@NatasaPeic
NatasaPeic / git-cheat-list.md
Created February 20, 2017 16:02
Git cheat list

Git cheat list

  • name of the current banch and nothing else (for automation)

    git rev-parse --abbrev-ref HEAD
    
  • all commits that your branch have that are not yet in master

    git log master..<HERE_COMES_YOUR_BRANCH_NAME>
    
@NatasaPeic
NatasaPeic / README.md
Created April 5, 2017 18:48 — forked from bycoffe/README.md
Town/county map using d3 and TopoJSON

This is a demonstration of how to create a combination town/county map from a shapefile using TopoJSON and d3.js.

It includes a simplified version of the code used for the Massachusetts special Senate election results on The Huffington Post.

Get the data

Download a shapefile of Massachusetts towns from the state's GIS site:

wget http://wsgw.mass.gov/data/gispub/shape/census2000/towns/census2000towns_poly.exe
@NatasaPeic
NatasaPeic / on-jsx.markdown
Created April 27, 2017 18:56 — forked from chantastic/on-jsx.markdown
JSX, a year in

Hi Nicholas,

I saw you tweet about JSX yesterday. It seemed like the discussion devolved pretty quickly but I wanted to share our experience over the last year. I understand your concerns. I've made similar remarks about JSX. When we started using it Planning Center, I lead the charge to write React without it. I don't imagine I'd have much to say that you haven't considered but, if it's helpful, here's a pattern that changed my opinion:

The idea that "React is the V in MVC" is disingenuous. It's a good pitch but, for many of us, it feels like in invitation to repeat our history of coupled views. In practice, React is the V and the C. Dan Abramov describes the division as Smart and Dumb Components. At our office, we call them stateless and container components (view-controllers if we're Flux). The idea is pretty simple: components can'

@NatasaPeic
NatasaPeic / bst.js
Created June 12, 2017 15:00 — forked from trevmex/bst.js
A simple binary search tree in JavaScript
/*
* File: bst.js
*
* A pure JavaScript implementation of a binary search tree.
*
*/
/*
* Class: BST
*