Class: Rubyvis::Line

Inherits:
Mark show all
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

Instance Method Summary collapse

Methods included from LinePrototype

#line_anchor

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_partition, #layout_partition_fill, #layout_stack, #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

.defaultsObject

Default properties for lines. By default, there is no fill and the stroke style is a categorical color. The default interpolation is linear.



146
147
148
149
# File 'lib/rubyvis/mark/line.rb', line 146

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.



131
132
133
# File 'lib/rubyvis/mark/line.rb', line 131

def anchor(name)
  line_anchor(name)
end

#bind(*args) ⇒ Object

Reuse Area’s implementation for segmented bind & build.



135
136
137
# File 'lib/rubyvis/mark/line.rb', line 135

def bind(*args) # :nodoc:
  area_bind(*args)
end

#build_instance(*args) ⇒ Object

Reuse Area’s implementation for segmented bind & build.



140
141
142
# File 'lib/rubyvis/mark/line.rb', line 140

def build_instance(*args) # :nodoc:
  area_build_instance(*args)
end

#line_widthObject

: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



107
# File 'lib/rubyvis/mark/line.rb', line 107

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

#typeObject

Type of line



109
110
111
# File 'lib/rubyvis/mark/line.rb', line 109

def type
  "line"
end