Constucts a stylist function with default settings. Stylist functions can be registered as “load” or “show” event handlers on GeoJSON layers for dynamic styling. The stylist can have any number of registered attributes and style properties that are evaluated for each GeoJSON feature. In addition, the stylist may have a title function which is used to compute the tooltip for each feature.
For example, here is a simple stylist that computes the stroke color for each element based on a PCI property threshold:
po.stylist() .attr("stroke", function(d) { return d.properties.PCI < 50 ? "red" : "green"; })
The registered values for each attribute, style or title are typically specified as functions. However, constants may also be used.
Stylists that do not change over time should register for “load” events. Stylists that depend on state that changes over time or with interaction, such as a time slider, should register for “show” events; this allows reshow to re-evaluate the stylist and update the display.
Adds a dynamic attribute with the given name n and value v. The name is specified as a string; for namespaced attributes, the prefixes “svg:” and “xlink:” may be used; additional prefixes may be registered with po.ns. The value may be specified either as a function, which is evaluated for each GeoJSON feature object, or as a constant for all features. Returns this.
Adds a dynamic style property with the given name n, value v, and optional priority p. The name is specified as a string. The value may be specified either as a function, which is evaluated for each GeoJSON feature object, or as a constant for all features. The priority is specified either as “important” or null. Returns this.
Sets the title value to v. The value may be specified either as a function, which is evaluated for each GeoJSON feature object, or as a constant for all features. Returns this.
Implementation note: titles are currently implemented using a child svg:title element for each feature’s path element. Not all browsers may support this form of tooltip.