Class: TChart::Label
- Inherits:
-
Object
- Object
- TChart::Label
- Defined in:
- lib/tchart/model/label.rb
Overview
An x or y axis label on the chart. X axis labels will be years, e.g. “2014”, “2015”, etc., and y axis labels will be descriptions of the items being plotted, e.g. “Ruby”, “C”, “C++”, etc. Responsible for generating TikZ code to render the label.
Instance Attribute Summary collapse
-
#coord ⇒ Object
readonly
Horizontal and vertical mid-point of label location.
-
#style ⇒ Object
readonly
TikZ style, must be defined in encompasing TeX document.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#width ⇒ Object
readonly
Required for text justification.
Class Method Summary collapse
-
.build_xlabel(coord, width, text) ⇒ Object
The difference between an x axis label and a y axis label is the TikZ style; x axis labels are generated with the style “xlabel”, y axis labels use “ylabel”.
-
.build_ylabel(coord, width, text) ⇒ Object
> Label.
Instance Method Summary collapse
-
#initialize(coord, width, style, text) ⇒ Label
constructor
A new instance of Label.
- #render(tex) ⇒ Object
Constructor Details
#initialize(coord, width, style, text) ⇒ Label
Returns a new instance of Label.
31 32 33 34 35 36 |
# File 'lib/tchart/model/label.rb', line 31 def initialize(coord, width, style, text) @coord = coord @width = width @style = style @text = text end |
Instance Attribute Details
#coord ⇒ Object (readonly)
Horizontal and vertical mid-point of label location.
11 12 13 |
# File 'lib/tchart/model/label.rb', line 11 def coord @coord end |
#style ⇒ Object (readonly)
TikZ style, must be defined in encompasing TeX document.
13 14 15 |
# File 'lib/tchart/model/label.rb', line 13 def style @style end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
14 15 16 |
# File 'lib/tchart/model/label.rb', line 14 def text @text end |
#width ⇒ Object (readonly)
Required for text justification.
12 13 14 |
# File 'lib/tchart/model/label.rb', line 12 def width @width end |
Class Method Details
.build_xlabel(coord, width, text) ⇒ Object
The difference between an x axis label and a y axis label is the TikZ style; x axis labels are generated with the style “xlabel”, y axis labels use “ylabel”. In the TeX document that embeds the chart, the x axis labels will usually be styled with centered text, whereas y axis labels will be left justified.
23 24 25 |
# File 'lib/tchart/model/label.rb', line 23 def self.build_xlabel(coord, width, text) # => Label Label.new(coord, width, "xlabel", text) end |
Instance Method Details
#render(tex) ⇒ Object
38 39 40 |
# File 'lib/tchart/model/label.rb', line 38 def render(tex) tex.label @coord, @width, @style, @text end |