Class: Rubyvis::Line
- Includes:
- AreaPrototype, LinePrototype
- Defined in:
- lib/rubyvis/mark/line.rb
Overview
Represents a series of connected line segments, or polyline, that can be stroked with a configurable color and thickness. Each articulation point in the line corresponds to a datum; for n points, n-1 connected line segments are drawn. The point is positioned using the box model. Arbitrary paths are also possible, allowing radar plots and other custom visualizations.
<p>Like areas, lines can be stroked and filled with arbitrary colors. In most cases, lines are only stroked, but the fill style can be used to construct arbitrary polygons.
Instance Attribute Summary
Attributes inherited from Mark
#_properties, #binds, #child_index, #parent, #proto, #root, #scale, #scene, #target
Class Method Summary collapse
-
.defaults ⇒ Object
Default properties for lines.
Instance Method Summary collapse
-
#anchor(name) ⇒ Object
Constructs a new line anchor with default properties.
-
#bind(*args) ⇒ Object
Reuse Area’s implementation for segmented bind & build.
-
#build_instance(*args) ⇒ Object
Reuse Area’s implementation for segmented bind & build.
-
#line_width ⇒ Object
:attr: tension The tension of cardinal splines; used in conjunction with interpolate(“cardinal”).
-
#type ⇒ Object
Type of line.
Methods included from LinePrototype
Methods included from AreaPrototype
#area_anchor, #area_bind, #area_build_instance, #fixed
Methods inherited from Mark
#add, #area, attr_accessor_dsl, #bar, #build, #build_implied, #build_properties, #context, #context_apply, #context_clear, #cousin, #delete_index, #dot, #event, #execute, #first, #image, index, #index, index=, #index=, #index_defined?, #initialize, #instance, #instances, #label, #last, #layout_arc, #layout_cluster, #layout_grid, #layout_horizon, #layout_indent, #layout_matrix, #layout_pack, #layout_partition, #layout_partition_fill, #layout_stack, #layout_tree, #layout_treemap, #line, #margin, #mark_anchor, #mark_bind, #mark_build_implied, #mark_build_instance, #mark_build_properties, #mark_extend, mark_method, #panel, #properties, properties, property_method, #property_value, #render, #rule, scene, scene=, #sibling, stack, stack=, #wedge
Constructor Details
This class inherits a constructor from Rubyvis::Mark
Class Method Details
.defaults ⇒ Object
Default properties for lines. By default, there is no fill and the stroke style is a categorical color. The default interpolation is linear.
147 148 149 150 |
# File 'lib/rubyvis/mark/line.rb', line 147 def self.defaults a=Rubyvis::Colors.category10() Line.new.mark_extend(Mark.defaults).line_join('miter').line_width(1.5).stroke_style( lambda { a.scale(parent.index)}).interpolate('linear').eccentricity(0).tension(0.7) end |
Instance Method Details
#anchor(name) ⇒ Object
Constructs a new line anchor with default properties. Lines 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 line. 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.
132 133 134 |
# File 'lib/rubyvis/mark/line.rb', line 132 def anchor(name) line_anchor(name) end |
#bind(*args) ⇒ Object
Reuse Area’s implementation for segmented bind & build.
136 137 138 |
# File 'lib/rubyvis/mark/line.rb', line 136 def bind(*args) # :nodoc: area_bind(*args) end |
#build_instance(*args) ⇒ Object
Reuse Area’s implementation for segmented bind & build.
141 142 143 |
# File 'lib/rubyvis/mark/line.rb', line 141 def build_instance(*args) # :nodoc: area_build_instance(*args) end |
#line_width ⇒ Object
:attr: tension The tension of cardinal splines; used in conjunction with interpolate(“cardinal”). A value between 0 and 1 draws cardinal splines with the given tension. In some sense, the tension can be interpreted as the “length” of the tangent; a tension of 1 will yield all zero tangents (i.e., linear interpolation), and a tension of 0 yields a Catmull-Rom spline. The default value is 0.7.
<p>This property is fixed. See Rubyvis.Mark
108 |
# File 'lib/rubyvis/mark/line.rb', line 108 attr_accessor_dsl :line_width, :line_join, [:stroke_style, lambda {|d| Rubyvis.color(d)}], [:fill_style, lambda {|d| Rubyvis.color(d)}], :segmented, :interpolate, :eccentricity, :tension |
#type ⇒ Object
Type of line
110 111 112 |
# File 'lib/rubyvis/mark/line.rb', line 110 def type "line" end |