Apply commit and branch labels using foreignObjects.

Only works in browser.
This commit is contained in:
Raghu Rajagopalan
2016-04-02 11:51:04 +05:30
parent 59ef2b0d4f
commit 5dcd3e6f35
4 changed files with 228 additions and 225 deletions

View File

@@ -324,7 +324,7 @@ process.umask = function() { return 0; };
},{}],4:[function(require,module,exports){ },{}],4:[function(require,module,exports){
!function() { !function() {
var d3 = { var d3 = {
version: "3.5.16" version: "3.5.6"
}; };
var d3_arraySlice = [].slice, d3_array = function(list) { var d3_arraySlice = [].slice, d3_array = function(list) {
return d3_arraySlice.call(list); return d3_arraySlice.call(list);
@@ -544,20 +544,20 @@ process.umask = function() { return 0; };
while (i < n) pairs[i] = [ p0 = p1, p1 = array[++i] ]; while (i < n) pairs[i] = [ p0 = p1, p1 = array[++i] ];
return pairs; return pairs;
}; };
d3.transpose = function(matrix) { d3.zip = function() {
if (!(n = matrix.length)) return []; if (!(n = arguments.length)) return [];
for (var i = -1, m = d3.min(matrix, d3_transposeLength), transpose = new Array(m); ++i < m; ) { for (var i = -1, m = d3.min(arguments, d3_zipLength), zips = new Array(m); ++i < m; ) {
for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n; ) { for (var j = -1, n, zip = zips[i] = new Array(n); ++j < n; ) {
row[j] = matrix[j][i]; zip[j] = arguments[j][i];
} }
} }
return transpose; return zips;
}; };
function d3_transposeLength(d) { function d3_zipLength(d) {
return d.length; return d.length;
} }
d3.zip = function() { d3.transpose = function(matrix) {
return d3.transpose(arguments); return d3.zip.apply(d3, matrix);
}; };
d3.keys = function(map) { d3.keys = function(map) {
var keys = []; var keys = [];
@@ -944,10 +944,9 @@ process.umask = function() { return 0; };
return d3_selectAll(selector, this); return d3_selectAll(selector, this);
}; };
} }
var d3_nsXhtml = "http://www.w3.org/1999/xhtml";
var d3_nsPrefix = { var d3_nsPrefix = {
svg: "http://www.w3.org/2000/svg", svg: "http://www.w3.org/2000/svg",
xhtml: d3_nsXhtml, xhtml: "http://www.w3.org/1999/xhtml",
xlink: "http://www.w3.org/1999/xlink", xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace", xml: "http://www.w3.org/XML/1998/namespace",
xmlns: "http://www.w3.org/2000/xmlns/" xmlns: "http://www.w3.org/2000/xmlns/"
@@ -956,7 +955,10 @@ process.umask = function() { return 0; };
prefix: d3_nsPrefix, prefix: d3_nsPrefix,
qualify: function(name) { qualify: function(name) {
var i = name.indexOf(":"), prefix = name; var i = name.indexOf(":"), prefix = name;
if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); if (i >= 0) {
prefix = name.slice(0, i);
name = name.slice(i + 1);
}
return d3_nsPrefix.hasOwnProperty(prefix) ? { return d3_nsPrefix.hasOwnProperty(prefix) ? {
space: d3_nsPrefix[prefix], space: d3_nsPrefix[prefix],
local: name local: name
@@ -1130,7 +1132,7 @@ process.umask = function() { return 0; };
function d3_selection_creator(name) { function d3_selection_creator(name) {
function create() { function create() {
var document = this.ownerDocument, namespace = this.namespaceURI; var document = this.ownerDocument, namespace = this.namespaceURI;
return namespace === d3_nsXhtml && document.documentElement.namespaceURI === d3_nsXhtml ? document.createElement(name) : document.createElementNS(namespace, name); return namespace ? document.createElementNS(namespace, name) : document.createElement(name);
} }
function createNS() { function createNS() {
return this.ownerDocument.createElementNS(name.space, name.local); return this.ownerDocument.createElementNS(name.space, name.local);
@@ -1167,14 +1169,12 @@ process.umask = function() { return 0; };
if (key) { if (key) {
var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue; var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue;
for (i = -1; ++i < n; ) { for (i = -1; ++i < n; ) {
if (node = group[i]) { if (nodeByKeyValue.has(keyValue = key.call(node = group[i], node.__data__, i))) {
if (nodeByKeyValue.has(keyValue = key.call(node, node.__data__, i))) { exitNodes[i] = node;
exitNodes[i] = node; } else {
} else { nodeByKeyValue.set(keyValue, node);
nodeByKeyValue.set(keyValue, node);
}
keyValues[i] = keyValue;
} }
keyValues[i] = keyValue;
} }
for (i = -1; ++i < m; ) { for (i = -1; ++i < m; ) {
if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) { if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) {
@@ -1186,7 +1186,7 @@ process.umask = function() { return 0; };
nodeByKeyValue.set(keyValue, true); nodeByKeyValue.set(keyValue, true);
} }
for (i = -1; ++i < n; ) { for (i = -1; ++i < n; ) {
if (i in keyValues && nodeByKeyValue.get(keyValues[i]) !== true) { if (nodeByKeyValue.get(keyValues[i]) !== true) {
exitNodes[i] = group[i]; exitNodes[i] = group[i];
} }
} }
@@ -1378,7 +1378,7 @@ process.umask = function() { return 0; };
group = d3_array(d3_selectAll(nodes, d3_document)); group = d3_array(d3_selectAll(nodes, d3_document));
group.parentNode = d3_document.documentElement; group.parentNode = d3_document.documentElement;
} else { } else {
group = d3_array(nodes); group = nodes;
group.parentNode = null; group.parentNode = null;
} }
return d3_selection([ group ]); return d3_selection([ group ]);
@@ -1529,7 +1529,7 @@ process.umask = function() { return 0; };
} }
function dragstart(id, position, subject, move, end) { function dragstart(id, position, subject, move, end) {
return function() { return function() {
var that = this, target = d3.event.target.correspondingElement || d3.event.target, parent = that.parentNode, dispatch = event.of(that, arguments), dragged = 0, dragId = id(), dragName = ".drag" + (dragId == null ? "" : "-" + dragId), dragOffset, dragSubject = d3.select(subject(target)).on(move + dragName, moved).on(end + dragName, ended), dragRestore = d3_event_dragSuppress(target), position0 = position(parent, dragId); var that = this, target = d3.event.target, parent = that.parentNode, dispatch = event.of(that, arguments), dragged = 0, dragId = id(), dragName = ".drag" + (dragId == null ? "" : "-" + dragId), dragOffset, dragSubject = d3.select(subject(target)).on(move + dragName, moved).on(end + dragName, ended), dragRestore = d3_event_dragSuppress(target), position0 = position(parent, dragId);
if (origin) { if (origin) {
dragOffset = origin.apply(that, arguments); dragOffset = origin.apply(that, arguments);
dragOffset = [ dragOffset.x - position0[0], dragOffset.y - position0[1] ]; dragOffset = [ dragOffset.x - position0[0], dragOffset.y - position0[1] ];
@@ -1557,7 +1557,7 @@ process.umask = function() { return 0; };
function ended() { function ended() {
if (!position(parent, dragId)) return; if (!position(parent, dragId)) return;
dragSubject.on(move + dragName, null).on(end + dragName, null); dragSubject.on(move + dragName, null).on(end + dragName, null);
dragRestore(dragged); dragRestore(dragged && d3.event.target === target);
dispatch({ dispatch({
type: "dragend" type: "dragend"
}); });
@@ -1609,22 +1609,18 @@ process.umask = function() { return 0; };
} }
var ρ = Math.SQRT2, ρ2 = 2, ρ4 = 4; var ρ = Math.SQRT2, ρ2 = 2, ρ4 = 4;
d3.interpolateZoom = function(p0, p1) { d3.interpolateZoom = function(p0, p1) {
var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2], dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, i, S; var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2];
if (d2 < ε2) { var dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + ρ4 * d2) / (2 * w0 * ρ2 * d1), b1 = (w1 * w1 - w0 * w0 - ρ4 * d2) / (2 * w1 * ρ2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1), dr = r1 - r0, S = (dr || Math.log(w1 / w0)) / ρ;
S = Math.log(w1 / w0) / ρ; function interpolate(t) {
i = function(t) { var s = t * S;
return [ ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(ρ * t * S) ]; if (dr) {
}; var coshr0 = d3_cosh(r0), u = w0 / (ρ2 * d1) * (coshr0 * d3_tanh(ρ * s + r0) - d3_sinh(r0));
} else {
var d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + ρ4 * d2) / (2 * w0 * ρ2 * d1), b1 = (w1 * w1 - w0 * w0 - ρ4 * d2) / (2 * w1 * ρ2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
S = (r1 - r0) / ρ;
i = function(t) {
var s = t * S, coshr0 = d3_cosh(r0), u = w0 / (ρ2 * d1) * (coshr0 * d3_tanh(ρ * s + r0) - d3_sinh(r0));
return [ ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / d3_cosh(ρ * s + r0) ]; return [ ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / d3_cosh(ρ * s + r0) ];
}; }
return [ ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(ρ * s) ];
} }
i.duration = S * 1e3; interpolate.duration = S * 1e3;
return i; return interpolate;
}; };
d3.behavior.zoom = function() { d3.behavior.zoom = function() {
var view = { var view = {
@@ -1694,9 +1690,8 @@ process.umask = function() { return 0; };
view = { view = {
x: view.x, x: view.x,
y: view.y, y: view.y,
k: null k: +_
}; };
scaleTo(+_);
rescale(); rescale();
return zoom; return zoom;
}; };
@@ -1795,7 +1790,7 @@ process.umask = function() { return 0; };
}), center0 = null; }), center0 = null;
} }
function mousedowned() { function mousedowned() {
var that = this, dispatch = event.of(that, arguments), dragged = 0, subject = d3.select(d3_window(that)).on(mousemove, moved).on(mouseup, ended), location0 = location(d3.mouse(that)), dragRestore = d3_event_dragSuppress(that); var that = this, target = d3.event.target, dispatch = event.of(that, arguments), dragged = 0, subject = d3.select(d3_window(that)).on(mousemove, moved).on(mouseup, ended), location0 = location(d3.mouse(that)), dragRestore = d3_event_dragSuppress(that);
d3_selection_interrupt.call(that); d3_selection_interrupt.call(that);
zoomstarted(dispatch); zoomstarted(dispatch);
function moved() { function moved() {
@@ -1805,7 +1800,7 @@ process.umask = function() { return 0; };
} }
function ended() { function ended() {
subject.on(mousemove, null).on(mouseup, null); subject.on(mousemove, null).on(mouseup, null);
dragRestore(dragged); dragRestore(dragged && d3.event.target === target);
zoomended(dispatch); zoomended(dispatch);
} }
} }
@@ -2027,8 +2022,9 @@ process.umask = function() { return 0; };
return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16); return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16);
} }
function d3_rgb_parse(format, rgb, hsl) { function d3_rgb_parse(format, rgb, hsl) {
format = format.toLowerCase();
var r = 0, g = 0, b = 0, m1, m2, color; var r = 0, g = 0, b = 0, m1, m2, color;
m1 = /([a-z]+)\((.*)\)/.exec(format = format.toLowerCase()); m1 = /([a-z]+)\((.*)\)/.exec(format);
if (m1) { if (m1) {
m2 = m1[2].split(","); m2 = m1[2].split(",");
switch (m1[1]) { switch (m1[1]) {
@@ -2443,19 +2439,17 @@ process.umask = function() { return 0; };
}; };
d3.csv = d3.dsv(",", "text/csv"); d3.csv = d3.dsv(",", "text/csv");
d3.tsv = d3.dsv(" ", "text/tab-separated-values"); d3.tsv = d3.dsv(" ", "text/tab-separated-values");
var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout, d3_timer_frame = this[d3_vendorSymbol(this, "requestAnimationFrame")] || function(callback) { var d3_timer_queueHead, d3_timer_queueTail, d3_timer_interval, d3_timer_timeout, d3_timer_active, d3_timer_frame = this[d3_vendorSymbol(this, "requestAnimationFrame")] || function(callback) {
setTimeout(callback, 17); setTimeout(callback, 17);
}; };
d3.timer = function() { d3.timer = function(callback, delay, then) {
d3_timer.apply(this, arguments);
};
function d3_timer(callback, delay, then) {
var n = arguments.length; var n = arguments.length;
if (n < 2) delay = 0; if (n < 2) delay = 0;
if (n < 3) then = Date.now(); if (n < 3) then = Date.now();
var time = then + delay, timer = { var time = then + delay, timer = {
c: callback, c: callback,
t: time, t: time,
f: false,
n: null n: null
}; };
if (d3_timer_queueTail) d3_timer_queueTail.n = timer; else d3_timer_queueHead = timer; if (d3_timer_queueTail) d3_timer_queueTail.n = timer; else d3_timer_queueHead = timer;
@@ -2465,8 +2459,7 @@ process.umask = function() { return 0; };
d3_timer_interval = 1; d3_timer_interval = 1;
d3_timer_frame(d3_timer_step); d3_timer_frame(d3_timer_step);
} }
return timer; };
}
function d3_timer_step() { function d3_timer_step() {
var now = d3_timer_mark(), delay = d3_timer_sweep() - now; var now = d3_timer_mark(), delay = d3_timer_sweep() - now;
if (delay > 24) { if (delay > 24) {
@@ -2485,21 +2478,22 @@ process.umask = function() { return 0; };
d3_timer_sweep(); d3_timer_sweep();
}; };
function d3_timer_mark() { function d3_timer_mark() {
var now = Date.now(), timer = d3_timer_queueHead; var now = Date.now();
while (timer) { d3_timer_active = d3_timer_queueHead;
if (now >= timer.t && timer.c(now - timer.t)) timer.c = null; while (d3_timer_active) {
timer = timer.n; if (now >= d3_timer_active.t) d3_timer_active.f = d3_timer_active.c(now - d3_timer_active.t);
d3_timer_active = d3_timer_active.n;
} }
return now; return now;
} }
function d3_timer_sweep() { function d3_timer_sweep() {
var t0, t1 = d3_timer_queueHead, time = Infinity; var t0, t1 = d3_timer_queueHead, time = Infinity;
while (t1) { while (t1) {
if (t1.c) { if (t1.f) {
t1 = t0 ? t0.n = t1.n : d3_timer_queueHead = t1.n;
} else {
if (t1.t < time) time = t1.t; if (t1.t < time) time = t1.t;
t1 = (t0 = t1).n; t1 = (t0 = t1).n;
} else {
t1 = t0 ? t0.n = t1.n : d3_timer_queueHead = t1.n;
} }
} }
d3_timer_queueTail = t0; d3_timer_queueTail = t0;
@@ -2514,7 +2508,7 @@ process.umask = function() { return 0; };
var d3_formatPrefixes = [ "y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" ].map(d3_formatPrefix); var d3_formatPrefixes = [ "y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y" ].map(d3_formatPrefix);
d3.formatPrefix = function(value, precision) { d3.formatPrefix = function(value, precision) {
var i = 0; var i = 0;
if (value = +value) { if (value) {
if (value < 0) value *= -1; if (value < 0) value *= -1;
if (precision) value = d3.round(value, d3_format_precision(value, precision)); if (precision) value = d3.round(value, d3_format_precision(value, precision));
i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10); i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10);
@@ -2864,8 +2858,7 @@ process.umask = function() { return 0; };
if (i != string.length) return null; if (i != string.length) return null;
if ("p" in d) d.H = d.H % 12 + d.p * 12; if ("p" in d) d.H = d.H % 12 + d.p * 12;
var localZ = d.Z != null && d3_date !== d3_date_utc, date = new (localZ ? d3_date_utc : d3_date)(); var localZ = d.Z != null && d3_date !== d3_date_utc, date = new (localZ ? d3_date_utc : d3_date)();
if ("j" in d) date.setFullYear(d.y, 0, d.j); else if ("W" in d || "U" in d) { if ("j" in d) date.setFullYear(d.y, 0, d.j); else if ("w" in d && ("W" in d || "U" in d)) {
if (!("w" in d)) d.w = "W" in d ? 1 : 0;
date.setFullYear(d.y, 0, 1); date.setFullYear(d.y, 0, 1);
date.setFullYear(d.y, 0, "W" in d ? (d.w + 6) % 7 + d.W * 7 - (date.getDay() + 5) % 7 : d.w + d.U * 7 - (date.getDay() + 6) % 7); date.setFullYear(d.y, 0, "W" in d ? (d.w + 6) % 7 + d.W * 7 - (date.getDay() + 5) % 7 : d.w + d.U * 7 - (date.getDay() + 6) % 7);
} else date.setFullYear(d.y, d.m, d.d); } else date.setFullYear(d.y, d.m, d.d);
@@ -6317,68 +6310,54 @@ process.umask = function() { return 0; };
f: 0 f: 0
}; };
d3.interpolateTransform = d3_interpolateTransform; d3.interpolateTransform = d3_interpolateTransform;
function d3_interpolateTransformPop(s) { function d3_interpolateTransform(a, b) {
return s.length ? s.pop() + "," : ""; var s = [], q = [], n, A = d3.transform(a), B = d3.transform(b), ta = A.translate, tb = B.translate, ra = A.rotate, rb = B.rotate, wa = A.skew, wb = B.skew, ka = A.scale, kb = B.scale;
} if (ta[0] != tb[0] || ta[1] != tb[1]) {
function d3_interpolateTranslate(ta, tb, s, q) { s.push("translate(", null, ",", null, ")");
if (ta[0] !== tb[0] || ta[1] !== tb[1]) {
var i = s.push("translate(", null, ",", null, ")");
q.push({ q.push({
i: i - 4, i: 1,
x: d3_interpolateNumber(ta[0], tb[0]) x: d3_interpolateNumber(ta[0], tb[0])
}, { }, {
i: i - 2, i: 3,
x: d3_interpolateNumber(ta[1], tb[1]) x: d3_interpolateNumber(ta[1], tb[1])
}); });
} else if (tb[0] || tb[1]) { } else if (tb[0] || tb[1]) {
s.push("translate(" + tb + ")"); s.push("translate(" + tb + ")");
} else {
s.push("");
} }
} if (ra != rb) {
function d3_interpolateRotate(ra, rb, s, q) {
if (ra !== rb) {
if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360; if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360;
q.push({ q.push({
i: s.push(d3_interpolateTransformPop(s) + "rotate(", null, ")") - 2, i: s.push(s.pop() + "rotate(", null, ")") - 2,
x: d3_interpolateNumber(ra, rb) x: d3_interpolateNumber(ra, rb)
}); });
} else if (rb) { } else if (rb) {
s.push(d3_interpolateTransformPop(s) + "rotate(" + rb + ")"); s.push(s.pop() + "rotate(" + rb + ")");
} }
} if (wa != wb) {
function d3_interpolateSkew(wa, wb, s, q) {
if (wa !== wb) {
q.push({ q.push({
i: s.push(d3_interpolateTransformPop(s) + "skewX(", null, ")") - 2, i: s.push(s.pop() + "skewX(", null, ")") - 2,
x: d3_interpolateNumber(wa, wb) x: d3_interpolateNumber(wa, wb)
}); });
} else if (wb) { } else if (wb) {
s.push(d3_interpolateTransformPop(s) + "skewX(" + wb + ")"); s.push(s.pop() + "skewX(" + wb + ")");
} }
} if (ka[0] != kb[0] || ka[1] != kb[1]) {
function d3_interpolateScale(ka, kb, s, q) { n = s.push(s.pop() + "scale(", null, ",", null, ")");
if (ka[0] !== kb[0] || ka[1] !== kb[1]) {
var i = s.push(d3_interpolateTransformPop(s) + "scale(", null, ",", null, ")");
q.push({ q.push({
i: i - 4, i: n - 4,
x: d3_interpolateNumber(ka[0], kb[0]) x: d3_interpolateNumber(ka[0], kb[0])
}, { }, {
i: i - 2, i: n - 2,
x: d3_interpolateNumber(ka[1], kb[1]) x: d3_interpolateNumber(ka[1], kb[1])
}); });
} else if (kb[0] !== 1 || kb[1] !== 1) { } else if (kb[0] != 1 || kb[1] != 1) {
s.push(d3_interpolateTransformPop(s) + "scale(" + kb + ")"); s.push(s.pop() + "scale(" + kb + ")");
} }
} n = q.length;
function d3_interpolateTransform(a, b) {
var s = [], q = [];
a = d3.transform(a), b = d3.transform(b);
d3_interpolateTranslate(a.translate, b.translate, s, q);
d3_interpolateRotate(a.rotate, b.rotate, s, q);
d3_interpolateSkew(a.skew, b.skew, s, q);
d3_interpolateScale(a.scale, b.scale, s, q);
a = b = null;
return function(t) { return function(t) {
var i = -1, n = q.length, o; var i = -1, o;
while (++i < n) s[(o = q[i]).i] = o.x(t); while (++i < n) s[(o = q[i]).i] = o.x(t);
return s.join(""); return s.join("");
}; };
@@ -6482,7 +6461,7 @@ process.umask = function() { return 0; };
index: di, index: di,
startAngle: x0, startAngle: x0,
endAngle: x, endAngle: x,
value: groupSums[di] value: (x - x0) / k
}; };
x += padding; x += padding;
} }
@@ -6550,7 +6529,7 @@ process.umask = function() { return 0; };
return chord; return chord;
}; };
d3.layout.force = function() { d3.layout.force = function() {
var force = {}, event = d3.dispatch("start", "tick", "end"), timer, size = [ 1, 1 ], drag, alpha, friction = .9, linkDistance = d3_layout_forceLinkDistance, linkStrength = d3_layout_forceLinkStrength, charge = -30, chargeDistance2 = d3_layout_forceChargeDistance2, gravity = .1, theta2 = .64, nodes = [], links = [], distances, strengths, charges; var force = {}, event = d3.dispatch("start", "tick", "end"), size = [ 1, 1 ], drag, alpha, friction = .9, linkDistance = d3_layout_forceLinkDistance, linkStrength = d3_layout_forceLinkStrength, charge = -30, chargeDistance2 = d3_layout_forceChargeDistance2, gravity = .1, theta2 = .64, nodes = [], links = [], distances, strengths, charges;
function repulse(node) { function repulse(node) {
return function(quad, x1, _, x2) { return function(quad, x1, _, x2) {
if (quad.point !== node) { if (quad.point !== node) {
@@ -6574,7 +6553,6 @@ process.umask = function() { return 0; };
} }
force.tick = function() { force.tick = function() {
if ((alpha *= .99) < .005) { if ((alpha *= .99) < .005) {
timer = null;
event.end({ event.end({
type: "end", type: "end",
alpha: alpha = 0 alpha: alpha = 0
@@ -6592,7 +6570,7 @@ process.umask = function() { return 0; };
l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l; l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l;
x *= l; x *= l;
y *= l; y *= l;
t.x -= x * (k = s.weight + t.weight ? s.weight / (s.weight + t.weight) : .5); t.x -= x * (k = s.weight / (t.weight + s.weight));
t.y -= y * k; t.y -= y * k;
s.x += x * (k = 1 - k); s.x += x * (k = 1 - k);
s.y += y * k; s.y += y * k;
@@ -6688,21 +6666,13 @@ process.umask = function() { return 0; };
if (!arguments.length) return alpha; if (!arguments.length) return alpha;
x = +x; x = +x;
if (alpha) { if (alpha) {
if (x > 0) { if (x > 0) alpha = x; else alpha = 0;
alpha = x;
} else {
timer.c = null, timer.t = NaN, timer = null;
event.end({
type: "end",
alpha: alpha = 0
});
}
} else if (x > 0) { } else if (x > 0) {
event.start({ event.start({
type: "start", type: "start",
alpha: alpha = x alpha: alpha = x
}); });
timer = d3_timer(force.tick); d3.timer(force.tick);
} }
return force; return force;
}; };
@@ -6956,7 +6926,7 @@ process.umask = function() { return 0; };
function pie(data) { function pie(data) {
var n = data.length, values = data.map(function(d, i) { var n = data.length, values = data.map(function(d, i) {
return +value.call(pie, d, i); return +value.call(pie, d, i);
}), a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle), da = (typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a, p = Math.min(Math.abs(da) / n, +(typeof padAngle === "function" ? padAngle.apply(this, arguments) : padAngle)), pa = p * (da < 0 ? -1 : 1), sum = d3.sum(values), k = sum ? (da - n * pa) / sum : 0, index = d3.range(n), arcs = [], v; }), a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle), da = (typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a, p = Math.min(Math.abs(da) / n, +(typeof padAngle === "function" ? padAngle.apply(this, arguments) : padAngle)), pa = p * (da < 0 ? -1 : 1), k = (da - n * pa) / d3.sum(values), index = d3.range(n), arcs = [], v;
if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) { if (sort != null) index.sort(sort === d3_layout_pieSortByValue ? function(i, j) {
return values[j] - values[i]; return values[j] - values[i];
} : function(i, j) { } : function(i, j) {
@@ -7669,8 +7639,10 @@ process.umask = function() { return 0; };
} }
function treemap(d) { function treemap(d) {
var nodes = stickies || hierarchy(d), root = nodes[0]; var nodes = stickies || hierarchy(d), root = nodes[0];
root.x = root.y = 0; root.x = 0;
if (root.value) root.dx = size[0], root.dy = size[1]; else root.dx = root.dy = 0; root.y = 0;
root.dx = size[0];
root.dy = size[1];
if (stickies) hierarchy.revalue(root); if (stickies) hierarchy.revalue(root);
scale([ root ], root.dx * root.dy / root.value); scale([ root ], root.dx * root.dy / root.value);
(stickies ? stickify : squarify)(root); (stickies ? stickify : squarify)(root);
@@ -7890,9 +7862,7 @@ process.umask = function() { return 0; };
return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp"); return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
} }
function d3_scale_linearNice(domain, m) { function d3_scale_linearNice(domain, m) {
d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2])); return d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2]));
d3_scale_nice(domain, d3_scale_niceStep(d3_scale_linearTickRange(domain, m)[2]));
return domain;
} }
function d3_scale_linearTickRange(domain, m) { function d3_scale_linearTickRange(domain, m) {
if (m == null) m = 10; if (m == null) m = 10;
@@ -7994,11 +7964,10 @@ process.umask = function() { return 0; };
scale.tickFormat = function(n, format) { scale.tickFormat = function(n, format) {
if (!arguments.length) return d3_scale_logFormat; if (!arguments.length) return d3_scale_logFormat;
if (arguments.length < 2) format = d3_scale_logFormat; else if (typeof format !== "function") format = d3.format(format); if (arguments.length < 2) format = d3_scale_logFormat; else if (typeof format !== "function") format = d3.format(format);
var k = Math.max(1, base * n / scale.ticks().length); var k = Math.max(.1, n / scale.ticks().length), f = positive ? (e = 1e-12, Math.ceil) : (e = -1e-12,
Math.floor), e;
return function(d) { return function(d) {
var i = d / pow(Math.round(log(d))); return d / pow(f(log(d) + e)) <= k ? format(d) : "";
if (i * base < base - .5) i *= base;
return i <= k ? format(d) : "";
}; };
}; };
scale.copy = function() { scale.copy = function() {
@@ -8337,16 +8306,11 @@ process.umask = function() { return 0; };
} else { } else {
x2 = y2 = 0; x2 = y2 = 0;
} }
if (da > ε && (rc = Math.min(Math.abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments))) > .001) { if ((rc = Math.min(Math.abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments))) > .001) {
cr = r0 < r1 ^ cw ? 0 : 1; cr = r0 < r1 ^ cw ? 0 : 1;
var rc1 = rc, rc0 = rc; var oc = x3 == null ? [ x2, y2 ] : x1 == null ? [ x0, y0 ] : d3_geom_polygonIntersect([ x0, y0 ], [ x3, y3 ], [ x1, y1 ], [ x2, y2 ]), ax = x0 - oc[0], ay = y0 - oc[1], bx = x1 - oc[0], by = y1 - oc[1], kc = 1 / Math.sin(Math.acos((ax * bx + ay * by) / (Math.sqrt(ax * ax + ay * ay) * Math.sqrt(bx * bx + by * by))) / 2), lc = Math.sqrt(oc[0] * oc[0] + oc[1] * oc[1]);
if (da < π) {
var oc = x3 == null ? [ x2, y2 ] : x1 == null ? [ x0, y0 ] : d3_geom_polygonIntersect([ x0, y0 ], [ x3, y3 ], [ x1, y1 ], [ x2, y2 ]), ax = x0 - oc[0], ay = y0 - oc[1], bx = x1 - oc[0], by = y1 - oc[1], kc = 1 / Math.sin(Math.acos((ax * bx + ay * by) / (Math.sqrt(ax * ax + ay * ay) * Math.sqrt(bx * bx + by * by))) / 2), lc = Math.sqrt(oc[0] * oc[0] + oc[1] * oc[1]);
rc0 = Math.min(rc, (r0 - lc) / (kc - 1));
rc1 = Math.min(rc, (r1 - lc) / (kc + 1));
}
if (x1 != null) { if (x1 != null) {
var t30 = d3_svg_arcCornerTangents(x3 == null ? [ x2, y2 ] : [ x3, y3 ], [ x0, y0 ], r1, rc1, cw), t12 = d3_svg_arcCornerTangents([ x1, y1 ], [ x2, y2 ], r1, rc1, cw); var rc1 = Math.min(rc, (r1 - lc) / (kc + 1)), t30 = d3_svg_arcCornerTangents(x3 == null ? [ x2, y2 ] : [ x3, y3 ], [ x0, y0 ], r1, rc1, cw), t12 = d3_svg_arcCornerTangents([ x1, y1 ], [ x2, y2 ], r1, rc1, cw);
if (rc === rc1) { if (rc === rc1) {
path.push("M", t30[0], "A", rc1, ",", rc1, " 0 0,", cr, " ", t30[1], "A", r1, ",", r1, " 0 ", 1 - cw ^ d3_svg_arcSweep(t30[1][0], t30[1][1], t12[1][0], t12[1][1]), ",", cw, " ", t12[1], "A", rc1, ",", rc1, " 0 0,", cr, " ", t12[0]); path.push("M", t30[0], "A", rc1, ",", rc1, " 0 0,", cr, " ", t30[1], "A", r1, ",", r1, " 0 ", 1 - cw ^ d3_svg_arcSweep(t30[1][0], t30[1][1], t12[1][0], t12[1][1]), ",", cw, " ", t12[1], "A", rc1, ",", rc1, " 0 0,", cr, " ", t12[0]);
} else { } else {
@@ -8356,7 +8320,7 @@ process.umask = function() { return 0; };
path.push("M", x0, ",", y0); path.push("M", x0, ",", y0);
} }
if (x3 != null) { if (x3 != null) {
var t03 = d3_svg_arcCornerTangents([ x0, y0 ], [ x3, y3 ], r0, -rc0, cw), t21 = d3_svg_arcCornerTangents([ x2, y2 ], x1 == null ? [ x0, y0 ] : [ x1, y1 ], r0, -rc0, cw); var rc0 = Math.min(rc, (r0 - lc) / (kc - 1)), t03 = d3_svg_arcCornerTangents([ x0, y0 ], [ x3, y3 ], r0, -rc0, cw), t21 = d3_svg_arcCornerTangents([ x2, y2 ], x1 == null ? [ x0, y0 ] : [ x1, y1 ], r0, -rc0, cw);
if (rc === rc0) { if (rc === rc0) {
path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t21[1], "A", r0, ",", r0, " 0 ", cw ^ d3_svg_arcSweep(t21[1][0], t21[1][1], t03[1][0], t03[1][1]), ",", 1 - cw, " ", t03[1], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]); path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t21[1], "A", r0, ",", r0, " 0 ", cw ^ d3_svg_arcSweep(t21[1][0], t21[1][1], t03[1][0], t03[1][1]), ",", 1 - cw, " ", t03[1], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]);
} else { } else {
@@ -8438,7 +8402,7 @@ process.umask = function() { return 0; };
return (x0 - x1) * y0 - (y0 - y1) * x0 > 0 ? 0 : 1; return (x0 - x1) * y0 - (y0 - y1) * x0 > 0 ? 0 : 1;
} }
function d3_svg_arcCornerTangents(p0, p1, r1, rc, cw) { function d3_svg_arcCornerTangents(p0, p1, r1, rc, cw) {
var x01 = p0[0] - p1[0], y01 = p0[1] - p1[1], lo = (cw ? rc : -rc) / Math.sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x1 = p0[0] + ox, y1 = p0[1] + oy, x2 = p1[0] + ox, y2 = p1[1] + oy, x3 = (x1 + x2) / 2, y3 = (y1 + y2) / 2, dx = x2 - x1, dy = y2 - y1, d2 = dx * dx + dy * dy, r = r1 - rc, D = x1 * y2 - x2 * y1, d = (dy < 0 ? -1 : 1) * Math.sqrt(Math.max(0, r * r * d2 - D * D)), cx0 = (D * dy - dx * d) / d2, cy0 = (-D * dx - dy * d) / d2, cx1 = (D * dy + dx * d) / d2, cy1 = (-D * dx + dy * d) / d2, dx0 = cx0 - x3, dy0 = cy0 - y3, dx1 = cx1 - x3, dy1 = cy1 - y3; var x01 = p0[0] - p1[0], y01 = p0[1] - p1[1], lo = (cw ? rc : -rc) / Math.sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x1 = p0[0] + ox, y1 = p0[1] + oy, x2 = p1[0] + ox, y2 = p1[1] + oy, x3 = (x1 + x2) / 2, y3 = (y1 + y2) / 2, dx = x2 - x1, dy = y2 - y1, d2 = dx * dx + dy * dy, r = r1 - rc, D = x1 * y2 - x2 * y1, d = (dy < 0 ? -1 : 1) * Math.sqrt(r * r * d2 - D * D), cx0 = (D * dy - dx * d) / d2, cy0 = (-D * dx - dy * d) / d2, cx1 = (D * dy + dx * d) / d2, cy1 = (-D * dx + dy * d) / d2, dx0 = cx0 - x3, dy0 = cy0 - y3, dx1 = cx1 - x3, dy1 = cy1 - y3;
if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1; if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1;
return [ [ cx0 - ox, cy0 - oy ], [ cx0 * r1 / r, cy0 * r1 / r ] ]; return [ [ cx0 - ox, cy0 - oy ], [ cx0 * r1 / r, cy0 * r1 / r ] ];
} }
@@ -8510,10 +8474,10 @@ process.umask = function() { return 0; };
value.closed = /-closed$/.test(key); value.closed = /-closed$/.test(key);
}); });
function d3_svg_lineLinear(points) { function d3_svg_lineLinear(points) {
return points.length > 1 ? points.join("L") : points + "Z"; return points.join("L");
} }
function d3_svg_lineLinearClosed(points) { function d3_svg_lineLinearClosed(points) {
return points.join("L") + "Z"; return d3_svg_lineLinear(points) + "Z";
} }
function d3_svg_lineStep(points) { function d3_svg_lineStep(points) {
var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ]; var i = 0, n = points.length, p = points[0], path = [ p[0], ",", p[1] ];
@@ -8535,7 +8499,7 @@ process.umask = function() { return 0; };
return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, -1), d3_svg_lineCardinalTangents(points, tension)); return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, -1), d3_svg_lineCardinalTangents(points, tension));
} }
function d3_svg_lineCardinalClosed(points, tension) { function d3_svg_lineCardinalClosed(points, tension) {
return points.length < 3 ? d3_svg_lineLinearClosed(points) : points[0] + d3_svg_lineHermite((points.push(points[0]), return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite((points.push(points[0]),
points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension)); points), d3_svg_lineCardinalTangents([ points[points.length - 2] ].concat(points, [ points[1] ]), tension));
} }
function d3_svg_lineCardinal(points, tension) { function d3_svg_lineCardinal(points, tension) {
@@ -8971,11 +8935,9 @@ process.umask = function() { return 0; };
var d3_selection_interrupt = d3_selection_interruptNS(d3_transitionNamespace()); var d3_selection_interrupt = d3_selection_interruptNS(d3_transitionNamespace());
function d3_selection_interruptNS(ns) { function d3_selection_interruptNS(ns) {
return function() { return function() {
var lock, activeId, active; var lock, active;
if ((lock = this[ns]) && (active = lock[activeId = lock.active])) { if ((lock = this[ns]) && (active = lock[lock.active])) {
active.timer.c = null; if (--lock.count) delete lock[lock.active]; else delete this[ns];
active.timer.t = NaN;
if (--lock.count) delete lock[activeId]; else delete this[ns];
lock.active += .5; lock.active += .5;
active.event && active.event.interrupt.call(this, this.__data__, active.index); active.event && active.event.interrupt.call(this, this.__data__, active.index);
} }
@@ -9230,68 +9192,12 @@ process.umask = function() { return 0; };
var lock = node[ns] || (node[ns] = { var lock = node[ns] || (node[ns] = {
active: 0, active: 0,
count: 0 count: 0
}), transition = lock[id], time, timer, duration, ease, tweens; }), transition = lock[id];
function schedule(elapsed) {
var delay = transition.delay;
timer.t = delay + time;
if (delay <= elapsed) return start(elapsed - delay);
timer.c = start;
}
function start(elapsed) {
var activeId = lock.active, active = lock[activeId];
if (active) {
active.timer.c = null;
active.timer.t = NaN;
--lock.count;
delete lock[activeId];
active.event && active.event.interrupt.call(node, node.__data__, active.index);
}
for (var cancelId in lock) {
if (+cancelId < id) {
var cancel = lock[cancelId];
cancel.timer.c = null;
cancel.timer.t = NaN;
--lock.count;
delete lock[cancelId];
}
}
timer.c = tick;
d3_timer(function() {
if (timer.c && tick(elapsed || 1)) {
timer.c = null;
timer.t = NaN;
}
return 1;
}, 0, time);
lock.active = id;
transition.event && transition.event.start.call(node, node.__data__, i);
tweens = [];
transition.tween.forEach(function(key, value) {
if (value = value.call(node, node.__data__, i)) {
tweens.push(value);
}
});
ease = transition.ease;
duration = transition.duration;
}
function tick(elapsed) {
var t = elapsed / duration, e = ease(t), n = tweens.length;
while (n > 0) {
tweens[--n].call(node, e);
}
if (t >= 1) {
transition.event && transition.event.end.call(node, node.__data__, i);
if (--lock.count) delete lock[id]; else delete node[ns];
return 1;
}
}
if (!transition) { if (!transition) {
time = inherit.time; var time = inherit.time;
timer = d3_timer(schedule, 0, time);
transition = lock[id] = { transition = lock[id] = {
tween: new d3_Map(), tween: new d3_Map(),
time: time, time: time,
timer: timer,
delay: inherit.delay, delay: inherit.delay,
duration: inherit.duration, duration: inherit.duration,
ease: inherit.ease, ease: inherit.ease,
@@ -9299,6 +9205,49 @@ process.umask = function() { return 0; };
}; };
inherit = null; inherit = null;
++lock.count; ++lock.count;
d3.timer(function(elapsed) {
var delay = transition.delay, duration, ease, timer = d3_timer_active, tweened = [];
timer.t = delay + time;
if (delay <= elapsed) return start(elapsed - delay);
timer.c = start;
function start(elapsed) {
if (lock.active > id) return stop();
var active = lock[lock.active];
if (active) {
--lock.count;
delete lock[lock.active];
active.event && active.event.interrupt.call(node, node.__data__, active.index);
}
lock.active = id;
transition.event && transition.event.start.call(node, node.__data__, i);
transition.tween.forEach(function(key, value) {
if (value = value.call(node, node.__data__, i)) {
tweened.push(value);
}
});
ease = transition.ease;
duration = transition.duration;
d3.timer(function() {
timer.c = tick(elapsed || 1) ? d3_true : tick;
return 1;
}, 0, time);
}
function tick(elapsed) {
if (lock.active !== id) return 1;
var t = elapsed / duration, e = ease(t), n = tweened.length;
while (n > 0) {
tweened[--n].call(node, e);
}
if (t >= 1) {
transition.event && transition.event.end.call(node, node.__data__, i);
return stop();
}
}
function stop() {
if (--lock.count) delete lock[id]; else delete node[ns];
return 1;
}
}, 0, time);
} }
} }
d3.svg.axis = function() { d3.svg.axis = function() {
@@ -9352,7 +9301,7 @@ process.umask = function() { return 0; };
}; };
axis.ticks = function() { axis.ticks = function() {
if (!arguments.length) return tickArguments_; if (!arguments.length) return tickArguments_;
tickArguments_ = d3_array(arguments); tickArguments_ = arguments;
return axis; return axis;
}; };
axis.tickValues = function(x) { axis.tickValues = function(x) {
@@ -9874,7 +9823,8 @@ process.umask = function() { return 0; };
d3.xml = d3_xhrType(function(request) { d3.xml = d3_xhrType(function(request) {
return request.responseXML; return request.responseXML;
}); });
if (typeof define === "function" && define.amd) this.d3 = d3, define(d3); else if (typeof module === "object" && module.exports) module.exports = d3; else this.d3 = d3; if (typeof define === "function" && define.amd) define(d3); else if (typeof module === "object" && module.exports) module.exports = d3;
this.d3 = d3;
}(); }();
},{}],5:[function(require,module,exports){ },{}],5:[function(require,module,exports){
/** /**
@@ -53653,7 +53603,13 @@ var config = {
lineStrokeWidth: 4, lineStrokeWidth: 4,
branchLineHeight: 50, branchLineHeight: 50,
lineColor: "grey", lineColor: "grey",
leftMargin: 50 leftMargin: 50,
nodeLabel: {
width: 50,
height: 100,
x: -25,
y: 25
}
}; };
var apiConfig = {}; var apiConfig = {};
exports.setConf = function (c) { exports.setConf = function (c) {
@@ -53662,15 +53618,7 @@ exports.setConf = function (c) {
function svgCreateDefs(svg) { function svgCreateDefs(svg) {
svg.append("defs").append("g").attr("id", "def-commit").append("circle").attr("r", 15).attr("cx", 0).attr("cy", 0); svg.append("defs").append("g").attr("id", "def-commit").append("circle").attr("r", 15).attr("cx", 0).attr("cy", 0);
svg.select("#def-commit").append('foreignObject').attr('width', 100).attr('height', 100).attr('x', 50).attr('y', 50).attr('requiredFeatures', 'http://www.w3.org/TR/SVG11/feature#Extensibility').append('xhtml:p').text("a big chunk of text that should wrap"); svg.select("#def-commit").append('foreignObject').attr('width', config.nodeLabel.width).attr('height', config.nodeLabel.height).attr('x', config.nodeLabel.x).attr('y', config.nodeLabel.y).attr('class', "node-label").attr('requiredFeatures', 'http://www.w3.org/TR/SVG11/feature#Extensibility').append('xhtml:p').html("a big chunk of text that should wrap");
//.attr("requiredExtensions", "http://www.w3.org/1999/xhtml")
//.attr("width", 50)
//.attr("height", 30)
//.attr("x", 30)
//.attr("y", 30)
//.append("xhtml:body")
//.append("xhtml:p")
//.text("something")
} }
function svgDrawLine(svg, points, interpolate) { function svgDrawLine(svg, points, interpolate) {
@@ -53746,6 +53694,11 @@ function renderCommitHistory(svg, commitid, branches, direction) {
return "translate(" + (commit.seq * config.nodeWidth + config.leftMargin) + ", " + branchNum * config.branchLineHeight + ")"; return "translate(" + (commit.seq * config.nodeWidth + config.leftMargin) + ", " + branchNum * config.branchLineHeight + ")";
}).attr("fill", "yellow").attr("stroke", "grey").attr("stroke-width", "2"); }).attr("fill", "yellow").attr("stroke", "grey").attr("stroke-width", "2");
svg.select("#node-" + commit.id + " p").text(commit.id);
var branch = _.find(branches, ["commit", commit]);
if (branch) {
svg.select("#node-" + commit.id + " foreignObject").append("xhtml:p").attr("class", "branch-label").text(branch.name);
}
commitid = commit.parent; commitid = commit.parent;
} while (commitid && allCommitsDict[commitid]); } while (commitid && allCommitsDict[commitid]);
} }

View File

@@ -12,7 +12,13 @@ var config = {
lineStrokeWidth: 4, lineStrokeWidth: 4,
branchLineHeight: 50, branchLineHeight: 50,
lineColor: "grey", lineColor: "grey",
leftMargin: 50 leftMargin: 50,
nodeLabel: {
width: 50,
height: 100,
x: -25,
y: 25
}
} }
var apiConfig = {}; var apiConfig = {};
exports.setConf = function(c) { exports.setConf = function(c) {
@@ -21,7 +27,8 @@ exports.setConf = function(c) {
function svgCreateDefs(svg) { function svgCreateDefs(svg) {
svg.append("defs") svg
.append("defs")
.append("g") .append("g")
.attr("id", "def-commit") .attr("id", "def-commit")
.append("circle") .append("circle")
@@ -30,21 +37,14 @@ function svgCreateDefs(svg) {
.attr("cy", 0); .attr("cy", 0);
svg.select("#def-commit") svg.select("#def-commit")
.append('foreignObject') .append('foreignObject')
.attr('width', 100) .attr('width', config.nodeLabel.width)
.attr('height', 100) .attr('height', config.nodeLabel.height)
.attr('x', 50) .attr('x', config.nodeLabel.x)
.attr('y', 50) .attr('y', config.nodeLabel.y)
.attr('class', "node-label")
.attr('requiredFeatures', 'http://www.w3.org/TR/SVG11/feature#Extensibility') .attr('requiredFeatures', 'http://www.w3.org/TR/SVG11/feature#Extensibility')
.append('xhtml:p') .append('xhtml:p')
.text("a big chunk of text that should wrap"); .html("a big chunk of text that should wrap");
//.attr("requiredExtensions", "http://www.w3.org/1999/xhtml")
//.attr("width", 50)
//.attr("height", 30)
//.attr("x", 30)
//.attr("y", 30)
//.append("xhtml:body")
//.append("xhtml:p")
//.text("something")
} }
@@ -141,6 +141,15 @@ function renderCommitHistory(svg, commitid, branches, direction) {
.attr("stroke", "grey") .attr("stroke", "grey")
.attr("stroke-width", "2"); .attr("stroke-width", "2");
svg.select("#node-" + commit.id + " p")
.text(commit.id);
var branch = _.find(branches, ["commit", commit]);
if (branch) {
svg.select("#node-" + commit.id + " foreignObject")
.append("xhtml:p")
.attr("class", "branch-label")
.text(branch.name);
}
commitid = commit.parent commitid = commit.parent
} while (commitid && allCommitsDict[commitid]); } while (commitid && allCommitsDict[commitid]);
} }

39
src/test.html Normal file
View File

@@ -0,0 +1,39 @@
<html>
<head>
<meta charset="utf-8">
<title></title>
<script src="..\dist\mermaid.js"></script>
<script>mermaid.initialize({startOnLoad:true});</script>
<style>
.node-label p {
margin:0px;
font-size:12px;
}
p.branch-label {
font-weight:bold;
}
</style>
</head>
<body>
<div class="mermaid">
gitGraph :
options
{"key": "value",
"nodeWidth": 150
}
end
commit
commit
commit
branch newbranch
checkout newbranch
commit
commit
merge master
checkout master
commit
commit
</div>
</body>

View File

@@ -1,7 +1,9 @@
gitGraph : gitGraph :
options options
{"key": "value", {"key": "value",
"nodeWidth": 100 "nodeWidth": 150
} }
end end
commit commit
commit
commit