Class: Rubyvis::Bar

Inherits:
Mark show all
Defined in:
lib/rubyvis/mark/bar.rb

Overview

Represents a bar: an axis-aligned rectangle that can be stroked and filled. Bars are used for many chart types, including bar charts, histograms and Gantt charts. Bars can also be used as decorations, for example to draw a frame border around a panel; in fact, a panel is a special type (a subclass) of bar.

Bars can be positioned in several ways. Most commonly, one of the four corners is fixed using two margins, and then the width and height properties determine the extent of the bar relative to this fixed location. For example, using the bottom and left properties fixes the bottom-left corner; the width then extends to the right, while the height extends to the top. As an alternative to the four corners, a bar can be positioned exclusively using margins; this is convenient as an inset from the containing panel, for example. See Mark for details on the prioritization of redundant positioning properties.

Direct Known Subclasses

Image, Panel

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 inherited from Mark

#add, #anchor, #area, attr_accessor_dsl, #bar, #bind, #build, #build_implied, #build_instance, #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

.defaultsObject

Default properties for bars. By default, there is no stroke and the fill style is a categorical color.



62
63
64
65
66
67
# File 'lib/rubyvis/mark/bar.rb', line 62

def self.defaults
  a=Rubyvis.Colors.category20()
  Bar.new.mark_extend(Mark.defaults).line_width(1.5).fill_style( lambda {
      a.scale(self.parent.index)
  })
end

Instance Method Details

#typeObject

:nodoc:



24
25
26
# File 'lib/rubyvis/mark/bar.rb', line 24

def type # :nodoc:
  "bar"
end

#widthObject

:attr: fill_style The bar fill style; if non-nil, the interior of the bar is filled with the specified color. The default value of this property is a categorical color.



58
# File 'lib/rubyvis/mark/bar.rb', line 58

attr_accessor_dsl :width, :height, :line_width, [:stroke_style, lambda {|d| Rubyvis.color(d)}], [:fill_style, lambda {|d| Rubyvis.color(d)}]