Class: TChart::YItem

Inherits:
Object
  • Object
show all
Defined in:
lib/tchart/model/y_item.rb

Overview

The input data file specifies settings, data lines, and separators. A data line consists of a description, which becomes a y axis label, zero or more date ranges to be plotted on the chart as horizontal bars, and a TikZ style for the bars. YItem is reponsible for capturing all of that information and for building the label and bar elements.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description, bar_style, date_ranges) ⇒ YItem

Returns a new instance of YItem.



16
17
18
19
20
# File 'lib/tchart/model/y_item.rb', line 16

def initialize(description, bar_style, date_ranges)
   @description = description
   @bar_style = bar_style
   @date_ranges = date_ranges
end

Instance Attribute Details

#bar_styleObject (readonly)

TikZ style, must be defined in encompasing TeX document.



13
14
15
# File 'lib/tchart/model/y_item.rb', line 13

def bar_style
  @bar_style
end

#date_rangesObject (readonly)

Can be >= 0; drawn as bars on the chart.



14
15
16
# File 'lib/tchart/model/y_item.rb', line 14

def date_ranges
  @date_ranges
end

#descriptionObject (readonly)

Used for the y-label.



12
13
14
# File 'lib/tchart/model/y_item.rb', line 12

def description
  @description
end

Instance Method Details

#build(layout, y) ⇒ Object

> [ Label, Bar, Bar, … ]



22
23
24
# File 'lib/tchart/model/y_item.rb', line 22

def build(layout, y) # => [ Label, Bar, Bar, ... ]
  [ new_y_label(layout, y) ].concat new_bars(layout, y)
end