1 /** 2 * Constructs a new, empty layout with default properties. Layouts are not 3 * typically constructed directly; instead, a concrete subclass is added to an 4 * existing panel via {@link pv.Mark#add}. 5 * 6 * @class Represents an abstract layout, encapsulating a visualization technique 7 * such as a streamgraph or treemap. Layouts are themselves containers, 8 * extending from {@link pv.Panel}, and defining a set of mark prototypes as 9 * children. These mark prototypes provide default properties that together 10 * implement the given visualization technique. 11 * 12 * <p>Layouts do not initially contain any marks; any exported marks (such as a 13 * network layout's <tt>link</tt> and <tt>node</tt>) are intended to be used as 14 * prototypes. By adding a concrete mark, such as a {@link pv.Bar}, to the 15 * appropriate mark prototype, the mark is added to the layout and inherits the 16 * given properties. This approach allows further customization of the layout, 17 * either by choosing a different mark type to add, or more simply by overriding 18 * some of the layout's defined properties. 19 * 20 * <p>Each concrete layout, such as treemap or circle-packing, has different 21 * behavior and may export different mark prototypes, depending on what marks 22 * are typically needed to render the desired visualization. Therefore it is 23 * important to understand how each layout is structured, such that the provided 24 * mark prototypes are used appropriately. 25 * 26 * <p>In addition to the mark prototypes, layouts may define custom properties 27 * that affect the overall behavior of the layout. For example, a treemap layout 28 * might use a property to specify which layout algorithm to use. These 29 * properties are just like other mark properties, and can be defined as 30 * constants or as functions. As with panels, the data property can be used to 31 * replicate layouts, and properties can be defined to in terms of layout data. 32 * 33 * @extends pv.Panel 34 */ 35 pv.Layout = function() { 36 pv.Panel.call(this); 37 }; 38 39 pv.Layout.prototype = pv.extend(pv.Panel); 40 41 /** 42 * @private Defines a local property with the specified name and cast. Note that 43 * although the property method is only defined locally, the cast function is 44 * global, which is necessary since properties are inherited! 45 * 46 * @param {string} name the property name. 47 * @param {function} [cast] the cast function for this property. 48 */ 49 pv.Layout.prototype.property = function(name, cast) { 50 if (!this.hasOwnProperty("properties")) { 51 this.properties = pv.extend(this.properties); 52 } 53 this.properties[name] = true; 54 this.propertyMethod(name, false, pv.Mark.cast[name] = cast); 55 return this; 56 }; 57