From 9586e5843d8de7293b52e1369a10cab5bdf29d14 Mon Sep 17 00:00:00 2001 From: peferron Date: Sat, 29 Dec 2012 12:43:40 -0800 Subject: [PATCH 1/2] Fixed bug on rule.remove context.rule creates a line with the datum {id: id}. In the rule focus handler, this whole datum is set to an integer i, and the id is lost. rule.remove will then throw an error because it tries to access d.id (with d being the datum) but the datum is just an integer now and has no 'id' property. The fix consists of simply adding the integer i as an additional property of the datum instead of completely replacing it. --- cubism.v1.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cubism.v1.js b/cubism.v1.js index 15eeb3c..dc0fd93 100644 --- a/cubism.v1.js +++ b/cubism.v1.js @@ -1004,9 +1004,9 @@ cubism_contextPrototype.rule = function() { }); context.on("focus.rule-" + id, function(i) { - line.datum(i) - .style("display", i == null ? "none" : null) - .style("left", i == null ? null : cubism_ruleLeft); + line.style("display", i == null ? "none" : null) + .style("left", i == null ? null : cubism_ruleLeft) + .datum().i = i; }); } @@ -1039,7 +1039,7 @@ function cubism_ruleStyle(line) { .style("pointer-events", "none"); } -function cubism_ruleLeft(i) { - return i + "px"; +function cubism_ruleLeft(d) { + return d.i + "px"; } })(this); From 91dd831c6a86e3d9a50bf32f53f5f06fa56549c0 Mon Sep 17 00:00:00 2001 From: peferron Date: Sun, 30 Dec 2012 15:41:45 -0800 Subject: [PATCH 2/2] Fix previous commit, datum should be updated first --- cubism.v1.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cubism.v1.js b/cubism.v1.js index dc0fd93..177b68b 100644 --- a/cubism.v1.js +++ b/cubism.v1.js @@ -1004,9 +1004,9 @@ cubism_contextPrototype.rule = function() { }); context.on("focus.rule-" + id, function(i) { + line.datum().i = i; line.style("display", i == null ? "none" : null) - .style("left", i == null ? null : cubism_ruleLeft) - .datum().i = i; + .style("left", i == null ? null : cubism_ruleLeft); }); }