class Rubyvis::Dot

Represents a dot; a dot is simply a sized glyph centered at a given point that can also be stroked and filled. The size property is proportional to the area of the rendered glyph to encourage meaningful visual encodings. Dots can visually encode up to eight dimensions of data, though this may be unwise due to integrality. See Mark for details on the prioritization of redundant positioning properties.



The fill style; if non-nil, the interior of the dot is filled with the specified color. The default value of this property is nil, meaning dots are not filled by default. See Rubyvis.color


The width of stroked lines, in pixels; used in conjunction with stroke_style to stroke the dot’s shape.


The shape name. Several shapes are supported:<ul>

<li>cross <li>triangle <li>diamond <li>square <li>circle <li>tick <li>bar

</ul>These shapes can be further changed using the angle() property; for instance, a cross can be turned into a plus by rotating. Similarly, the tick, which is vertical by default, can be rotated horizontally. Note that some shapes (cross and tick) do not have interior areas, and thus do not support fill style meaningfully.

<p>Note: it may be more natural to use the Rule mark for horizontal and vertical ticks. The tick shape is only necessary if angled ticks are needed.


The shape rotation angle, in radians. Used to rotate shapes, such as to turn a cross into a plus.


The radius of the shape, in pixels. This is an alternative to using #shape_size


The size of the shape, in square pixels. Square pixels are used such that the area of the shape is linearly proportional to the value of the shape_size property, facilitating representative encodings. This is an alternative to using #shape_radius


The style of stroked lines; used in conjunction with line_width to stroke the dot’s shape. The default value of this property is a categorical color. See Rubyvis.color

Public Class Methods

defaults() click to toggle source

Default properties for dots. By default, there is no fill and the stroke style is a categorical color. The default shape is “circle” with radius 4.5.

# File lib/rubyvis/mark/dot.rb, line 80
def self.defaults()
  a=Rubyvis::Colors.category10"circle"). line_width(1.5). stroke_style(lambda {a.scale(self.parent.index)})

Public Instance Methods

anchor(name) click to toggle source

Constructs a new dot anchor with default properties. Dots support five different anchors:<ul>

<li>top <li>left <li>center <li>bottom <li>right

</ul>In addition to positioning properties (left, right, top bottom), the anchors support text rendering properties (text-align, text-baseline). Text is rendered to appear outside the dot. Note that this behavior is different from other mark anchors, which default to rendering text inside the mark.

<p>For consistency with the other mark types, the anchor positions are defined in terms of their opposite edge. For example, the top anchor defines the bottom property, such that a bar added to the top anchor grows upward.

# File lib/rubyvis/mark/dot.rb, line 101
def anchor(name)
  mark_anchor(name).left(lambda {[self.index]
      when 'bottom' then s.left;
      when 'top' then s.left;
      when 'center' then s.left;
      when 'left' then nil;
  }).right(lambda {[self.index]'left' ? s.right+s.shape_radius : nil
  }).top(lambda {[self.index]
      when 'left' then;
      when 'right' then;
      when 'center' then;
      when 'top' then nil;
  }).bottom(lambda {[self.index]'top' ? s.bottom+s.shape_radius : nil
  }).text_align(lambda {
      when 'left' then  'right';
      when 'bottom' then 'center';
      when 'top' then 'center';
      when 'center' then 'center';
  }).text_baseline( lambda {
      when 'right' then  'middle';
      when 'left' then 'middle';
      when 'center' then 'middle';
      when 'bottom' then 'top';
type() click to toggle source

Type of mark

# File lib/rubyvis/mark/dot.rb, line 14
def type