1 /** 2 * Constructs a new bar mark with default properties. Bars are not typically 3 * constructed directly, but by adding to a panel or an existing mark via 4 * {@link pv.Mark#add}. 5 * 6 * @class Represents a bar: an axis-aligned rectangle that can be stroked and 7 * filled. Bars are used for many chart types, including bar charts, histograms 8 * and Gantt charts. Bars can also be used as decorations, for example to draw a 9 * frame border around a panel; in fact, a panel is a special type (a subclass) 10 * of bar. 11 * 12 * <p>Bars can be positioned in several ways. Most commonly, one of the four 13 * corners is fixed using two margins, and then the width and height properties 14 * determine the extent of the bar relative to this fixed location. For example, 15 * using the bottom and left properties fixes the bottom-left corner; the width 16 * then extends to the right, while the height extends to the top. As an 17 * alternative to the four corners, a bar can be positioned exclusively using 18 * margins; this is convenient as an inset from the containing panel, for 19 * example. See {@link pv.Mark} for details on the prioritization of redundant 20 * positioning properties. 21 * 22 * <p>See also the <a href="../../api/Bar.html">Bar guide</a>. 23 * 24 * @extends pv.Mark 25 */ 26 pv.Bar = function() { 27 pv.Mark.call(this); 28 }; 29 30 pv.Bar.prototype = pv.extend(pv.Mark) 31 .property("width", Number) 32 .property("height", Number) 33 .property("lineWidth", Number) 34 .property("strokeStyle", pv.color) 35 .property("fillStyle", pv.color); 36 37 pv.Bar.prototype.type = "bar"; 38 39 /** 40 * The width of the bar, in pixels. If the left position is specified, the bar 41 * extends rightward from the left edge; if the right position is specified, the 42 * bar extends leftward from the right edge. 43 * 44 * @type number 45 * @name pv.Bar.prototype.width 46 */ 47 48 /** 49 * The height of the bar, in pixels. If the bottom position is specified, the 50 * bar extends upward from the bottom edge; if the top position is specified, 51 * the bar extends downward from the top edge. 52 * 53 * @type number 54 * @name pv.Bar.prototype.height 55 */ 56 57 /** 58 * The width of stroked lines, in pixels; used in conjunction with 59 * <tt>strokeStyle</tt> to stroke the bar's border. 60 * 61 * @type number 62 * @name pv.Bar.prototype.lineWidth 63 */ 64 65 /** 66 * The style of stroked lines; used in conjunction with <tt>lineWidth</tt> to 67 * stroke the bar's border. The default value of this property is null, meaning 68 * bars are not stroked by default. 69 * 70 * @type string 71 * @name pv.Bar.prototype.strokeStyle 72 * @see pv.color 73 */ 74 75 /** 76 * The bar fill style; if non-null, the interior of the bar is filled with the 77 * specified color. The default value of this property is a categorical color. 78 * 79 * @type string 80 * @name pv.Bar.prototype.fillStyle 81 * @see pv.color 82 */ 83 84 /** 85 * Default properties for bars. By default, there is no stroke and the fill 86 * style is a categorical color. 87 * 88 * @type pv.Bar 89 */ 90 pv.Bar.prototype.defaults = new pv.Bar() 91 .extend(pv.Mark.prototype.defaults) 92 .lineWidth(1.5) 93 .fillStyle(pv.Colors.category20().by(pv.parent)); 94