Class: TChart::Settings
- Inherits:
-
Object
- Object
- TChart::Settings
- Defined in:
- lib/tchart/model/settings.rb
Overview
The input data file specifies settings, data lines, and separators. This class stores the settings from the data file. Responsible for providing default values for those settings that are not specified in the input file. Also responsible for answering whether a setting name is known or not, and for providing a list of all setting names.
All setting values are in millimeters. The Settings and TeXBuilder are the only two classes that know what units are being used. All other classes are unit agnostic.
Instance Attribute Summary collapse
-
#chart_width ⇒ Object
The amount of horizontal space available for the chart.
-
#line_height ⇒ Object
The amount of vertical space to allocate for each line of the chart.
-
#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.
-
#y_axis_label_width ⇒ Object
The width of the y axis labels.
Instance Method Summary collapse
- #has_setting?(setting_name) ⇒ Boolean
-
#initialize ⇒ Settings
constructor
A new instance of Settings.
-
#setting_names ⇒ Object
> [ “chart_width”, “line_height”, … ].
Constructor Details
#initialize ⇒ Settings
Returns a new instance of Settings.
49 50 51 52 53 54 55 |
# File 'lib/tchart/model/settings.rb', line 49 def initialize @chart_width = 164.99 @line_height = 4.6 @x_axis_label_width = 10 @x_axis_label_y_coordinate = -3 @y_axis_label_width = 24 end |
Instance Attribute Details
#chart_width ⇒ Object
The amount of horizontal space available for the chart. It must be large enough to accomodate the width of the y-axis labels, the width of the x axis, and the margins to the left and right of the x axis.
21 22 23 |
# File 'lib/tchart/model/settings.rb', line 21 def chart_width @chart_width end |
#line_height ⇒ Object
The amount of vertical space to allocate for each line of the chart. It must be large enough to accomodate the larger of the y axis label height and the bar height.
28 29 30 |
# File 'lib/tchart/model/settings.rb', line 28 def line_height @line_height end |
#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.
35 36 37 |
# File 'lib/tchart/model/settings.rb', line 35 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.
40 41 42 |
# File 'lib/tchart/model/settings.rb', line 40 def x_axis_label_y_coordinate @x_axis_label_y_coordinate 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.
47 48 49 |
# File 'lib/tchart/model/settings.rb', line 47 def y_axis_label_width @y_axis_label_width end |
Instance Method Details
#has_setting?(setting_name) ⇒ Boolean
57 58 59 |
# File 'lib/tchart/model/settings.rb', line 57 def has_setting?(setting_name) setting_names.include?(setting_name) end |
#setting_names ⇒ Object
> [ “chart_width”, “line_height”, … ]
61 62 63 64 65 |
# File 'lib/tchart/model/settings.rb', line 61 def setting_names # => [ "chart_width", "line_height", ... ] methods # => [ "has_setting?", "chart_width", "chart_width=", ... ] .grep(/\w=$/) # => [ "chart_width=", ... ] .map {|name| name.to_s.chomp('=')} # => [ "chart_width", ... ] end |