Class: TChart::Layout
- Inherits:
-
Object
- Object
- TChart::Layout
- Defined in:
- lib/tchart/model/layout.rb
Overview
Responsible for storing various chart metrics such as the length of the axes, the width of the axes labels, the coordinates of the axes labels, and so on. All metrics are unitless, although they should all be in the same unit. Also responsible for converting a date range to its equivalent start and end coordinates on the chart.
Instance Attribute Summary collapse
-
#x_axis_label_width ⇒ Object
The amount of horizontal space to allocate for each x axis label.
-
#x_axis_label_y_coordinate ⇒ Object
The distance of the mid point of the x axis labels from the x axis.
-
#x_axis_length ⇒ Object
The length of the x axis from the leftmost to the rightmost label.
-
#x_axis_tick_dates ⇒ Object
The dates to be used for the x axis labels.
-
#x_axis_tick_x_coordinates ⇒ Object
The x coordinates of the x axis labels and associated vertical grid lines.
-
#y_axis_label_width ⇒ Object
The width of the y axis labels.
-
#y_axis_label_x_coordinate ⇒ Object
The distance of the mid point of the y axis labels to the left of the y axis.
-
#y_axis_length ⇒ Object
The length of the y axis from the topmost to the bottommost item.
-
#y_axis_tick_y_coordinates ⇒ Object
The y coordinates of the y axis labels and their associated bars.
Instance Method Summary collapse
-
#date_range_to_x_coordinates(date_range) ⇒ Object
Convert a date range, e.g.
Instance Attribute Details
#x_axis_label_width ⇒ Object
The amount of horizontal space to allocate for each x axis label. Used to determine the width of the margins to the left and right of the x axis, and also passed to TikZ/TeX.
22 23 24 |
# File 'lib/tchart/model/layout.rb', line 22 def x_axis_label_width @x_axis_label_width end |
#x_axis_label_y_coordinate ⇒ Object
The distance of the mid point of the x axis labels from the x axis.
27 28 29 |
# File 'lib/tchart/model/layout.rb', line 27 def x_axis_label_y_coordinate @x_axis_label_y_coordinate end |
#x_axis_length ⇒ Object
The length of the x axis from the leftmost to the rightmost label.
15 16 17 |
# File 'lib/tchart/model/layout.rb', line 15 def x_axis_length @x_axis_length end |
#x_axis_tick_dates ⇒ Object
The dates to be used for the x axis labels.
38 39 40 |
# File 'lib/tchart/model/layout.rb', line 38 def x_axis_tick_dates @x_axis_tick_dates end |
#x_axis_tick_x_coordinates ⇒ Object
The x coordinates of the x axis labels and associated vertical grid lines.
33 34 35 |
# File 'lib/tchart/model/layout.rb', line 33 def x_axis_tick_x_coordinates @x_axis_tick_x_coordinates end |
#y_axis_label_width ⇒ Object
The width of the y axis labels. Used to calculate the amount of horizontal space to leave for the labels, and also passed in the generated TikX code.
50 51 52 |
# File 'lib/tchart/model/layout.rb', line 50 def y_axis_label_width @y_axis_label_width end |
#y_axis_label_x_coordinate ⇒ Object
The distance of the mid point of the y axis labels to the left of the y axis.
56 57 58 |
# File 'lib/tchart/model/layout.rb', line 56 def y_axis_label_x_coordinate @y_axis_label_x_coordinate end |
#y_axis_length ⇒ Object
The length of the y axis from the topmost to the bottommost item.
43 44 45 |
# File 'lib/tchart/model/layout.rb', line 43 def y_axis_length @y_axis_length end |
#y_axis_tick_y_coordinates ⇒ Object
The y coordinates of the y axis labels and their associated bars.
61 62 63 |
# File 'lib/tchart/model/layout.rb', line 61 def y_axis_tick_y_coordinates @y_axis_tick_y_coordinates end |
Instance Method Details
#date_range_to_x_coordinates(date_range) ⇒ Object
Convert a date range, e.g. Date.new(2000,1,1)..Date.new(2002,10,3), to its equivalent start and end coordinates on the chart.
67 68 69 70 71 |
# File 'lib/tchart/model/layout.rb', line 67 def date_range_to_x_coordinates(date_range) # => [ Numeric, Numeric ] x_from = date_to_x_coordinate(date_range.begin) x_to = date_to_x_coordinate(date_range.end + 1) # +1 bumps the time to end-of-day of the end date [x_from, x_to] end |