Skip to content
mbostock edited this page Apr 23, 2013 · 5 revisions

WikiAPI ReferenceRule

A thin vertical line that updates on mousemove. This is typically used to indicate the context's focus value. To create a rule, first create a context. For example:

var context = cubism.context(), // a default context
    rule = context.rule(); // a rule

# rule(selection)

Apply the rule to a D3 selection or transition containing one or more SVG element. For example:

d3.select("body").append("div")
    .attr("class", "rule")
    .call(rule);

# rule.metric([metric])

If metric is specified, sets this rule’s associated metric and returns the rule. If metric is not specified, returns the rule’s current metric which defaults to null. If a metric is associated with the rule, then a rule will be displayed at each non-zero value of the metric; otherwise, only a single rule will be displayed on mouseover at the mouse location. Binding a metric to a rule is a useful way to overlay events on a time-series, such as deploys.

# rule.remove(selection)

Removes the rule from a D3 selection, and removes any associated listeners. This method only removes the contents added by the rule itself; typically, you also want to call remove on the selection. For example:

d3.select(".rule")
    .call(rule.remove)
    .remove();

Requires that the elements in the selection were previously bound to this rule.

Clone this wiki locally