Skip to content

Instantly share code, notes, and snippets.

View yani-'s full-sized avatar
🏠
Working from home

Yani Iliev yani-

🏠
Working from home
View GitHub Profile
@yani-
yani- / node_debian_init.sh
Created August 28, 2012 22:20 — forked from obazoud/node_debian_init.sh
Daemon init script for node.js based app/server (DEBIAN/UBUNTU)
#! /bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
const width = $('svg').parent().width();
const height = width / 2.4;
const svg = d3.select('svg');
svg.attr('width', width);
svg.attr('height', height);
const margin = {
top : 20,
right : 80,
bottom : 30,
left : 30
};
const x = d3.scaleTime().rangeRound([0, chartWidth]);
const y = d3.scaleLinear().rangeRound([chartHeight, 0]);
const color = d3.scaleOrdinal(d3.schemeCategory10);
const timeFormat = d3.timeParse("%Y-%m-%d"),
const bisectDate = d3.bisector(d => parseTime(d.x)).left;
const color = d3.scaleOrdinal([
"#3498db",
"#2ecc71",
"#f1c40f",
"#e74c3c",
"#9b59b6",
"#f39c12",
"#1abc9c"
]);
const line = d3.line()
.x((d) => x(d.date))
.y((d) => y(d.count))
color.domain(d3.keys(data[0]).filter((key) => key !== 'date')
data.forEach(d => {
d.date = timeFormat(d.date);
});
const metrics = color.domain().map(name => {{
name : name,
values : data.map(d => {{
date : d.date,
count : +d[name]
}}
x.domain(d3.extent(data, d => d.date));
y.domain([
d3.min(metrics, c => d3.min(c.values, v => v.count)),
d3.max(metrics, c => d3.max(c.values, v => v.count))
]);
chartContainer
.append('g')
.attr('class', 'x axis')
.attr('transform', 'translate(0,' + height + ')')
.style('storke', '#000')
.call(d3.axisBottom(x));
chartContainer
.append('g')
.attr('class', 'y axis')