Class: RubyvisCharts::AbstractTimelineChart

Inherits:
AbstractChart show all
Defined in:
lib/rubyvis_charts/abstract_timeline_chart.rb

Defined Under Namespace

Modules: DefaultArguments

Constant Summary collapse

EXTRA_WEEKEND_BARS_WIDTH =
0.2
TITLE_TOP_INDENT =
-15

Instance Attribute Summary collapse

Attributes inherited from AbstractChart

#height, #inner_box_height, #inner_box_width, #padding, #parent_layer, #values, #width

Instance Method Summary collapse

Methods inherited from AbstractChart

#render

Constructor Details

#initialize(dates:, marks: DefaultArguments::MARKS, y_scale_max: DefaultArguments::Y_SCALE_MAX, numbers_formatter: DefaultArguments::NUMBERS_FORMATTER, numbers_color: DefaultArguments::NUMBERS_COLOR, numbers_font: DefaultArguments::NUMBERS_FONT, title_text: DefaultArguments::TITLE_TEXT, title_color: DefaultArguments::TITLE_COLOR, title_font: DefaultArguments::TITLE_FONT, dates_formatter: DefaultArguments::DATES_FORMATTER, dates_color: DefaultArguments::DATES_COLOR, dates_font: DefaultArguments::DATES_FONT, marks_color: DefaultArguments::MARKS_COLOR, marks_font: DefaultArguments::MARKS_FONT, marks_formatter: DefaultArguments::MARKS_FORMATTER, rules_color: DefaultArguments::RULES_COLOR, rules_count: DefaultArguments::RULES_COUNT, weekend_bar_color: DefaultArguments::WEEKEND_BAR_COLOR, timeline_width_ratio: DefaultArguments::TIMELINE_WIDTH_RATIO, dates_height_ratio: DefaultArguments::DATES_HEIGHT_RATIO, marks_height_ratio: DefaultArguments::MARKS_HEIGHT_RATIO, legend_titles: DefaultArguments::LEGEND_TITLES, legend_colors: DefaultArguments::LEGEND_COLORS, legend_text_color: DefaultArguments::LEGEND_TEXT_COLOR, legend_font: DefaultArguments::LEGEND_FONT, legend_shape: DefaultArguments::LEGEND_SHAPE, legend_chars: DefaultArguments::LEGEND_CHARS, custom_legend_offset: nil, threshold_number: DefaultArguments::THRESHOLD_NUMBER, threshold_color: DefaultArguments::THRESHOLD_COLOR, threshold_width: DefaultArguments::THRESHOLD_WIDTH, threshold_caption: DefaultArguments::THRESHOLD_CAPTION, **other) ⇒ AbstractTimelineChart

Returns a new instance of AbstractTimelineChart.



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 52

def initialize(
  dates:,
  marks: DefaultArguments::MARKS,
  y_scale_max: DefaultArguments::Y_SCALE_MAX,
  numbers_formatter: DefaultArguments::NUMBERS_FORMATTER,
  numbers_color: DefaultArguments::NUMBERS_COLOR,
  numbers_font: DefaultArguments::NUMBERS_FONT,
  title_text: DefaultArguments::TITLE_TEXT,
  title_color: DefaultArguments::TITLE_COLOR,
  title_font: DefaultArguments::TITLE_FONT,
  dates_formatter: DefaultArguments::DATES_FORMATTER,
  dates_color: DefaultArguments::DATES_COLOR,
  dates_font: DefaultArguments::DATES_FONT,
  marks_color: DefaultArguments::MARKS_COLOR,
  marks_font: DefaultArguments::MARKS_FONT,
  marks_formatter: DefaultArguments::MARKS_FORMATTER,
  rules_color: DefaultArguments::RULES_COLOR,
  rules_count: DefaultArguments::RULES_COUNT,
  weekend_bar_color: DefaultArguments::WEEKEND_BAR_COLOR,
  timeline_width_ratio: DefaultArguments::TIMELINE_WIDTH_RATIO,
  dates_height_ratio: DefaultArguments::DATES_HEIGHT_RATIO,
  marks_height_ratio: DefaultArguments::MARKS_HEIGHT_RATIO,
  legend_titles: DefaultArguments::LEGEND_TITLES,
  legend_colors: DefaultArguments::LEGEND_COLORS,
  legend_text_color: DefaultArguments::LEGEND_TEXT_COLOR,
  legend_font: DefaultArguments::LEGEND_FONT,
  legend_shape: DefaultArguments::LEGEND_SHAPE,
  legend_chars: DefaultArguments::LEGEND_CHARS,
  custom_legend_offset: nil,
  threshold_number: DefaultArguments::THRESHOLD_NUMBER,
  threshold_color: DefaultArguments::THRESHOLD_COLOR,
  threshold_width: DefaultArguments::THRESHOLD_WIDTH,
  threshold_caption: DefaultArguments::THRESHOLD_CAPTION,
  **other
)
  super(other)

  @dates = dates
  @marks = marks
  @y_scale_max = y_scale_max
  @numbers_formatter = numbers_formatter
  @numbers_color = numbers_color
  @numbers_font = numbers_font
  @title_text = title_text
  @title_color = title_color
  @title_font = title_font
  @dates_formatter = dates_formatter
  @dates_color = dates_color
  @marks_color = marks_color
  @marks_formatter = marks_formatter
  @marks_font = marks_font
  @rules_color = rules_color
  @rules_count = rules_count
  @weekend_bar_color = weekend_bar_color
  @timeline_width_ratio = timeline_width_ratio
  @dates_height_ratio = dates_height_ratio
  @marks_height_ratio = marks_height_ratio
  @legend_titles = legend_titles
  @legend_colors = legend_colors
  @legend_text_color = legend_text_color
  @legend_font = legend_font
  @legend_shape = legend_shape
  @legend_chars = legend_chars
  @dates_font = dates_font
  @custom_legend_offset = custom_legend_offset
  @threshold_number = threshold_number
  @threshold_color = threshold_color
  @threshold_width = threshold_width
  @threshold_caption = threshold_caption

  initialize_layers!

  initialize_weekend_bars!
  initialize_numbers!
  initialize_rules!
  initialize_title!
  initialize_dates!
  initialize_marks!
  initialize_threshold!
  initialize_legend!
end

Instance Attribute Details

#custom_legend_offsetObject (readonly)

Returns the value of attribute custom_legend_offset.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def custom_legend_offset
  @custom_legend_offset
end

#datesObject (readonly)

Returns the value of attribute dates.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def dates
  @dates
end

#dates_colorObject (readonly)

Returns the value of attribute dates_color.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def dates_color
  @dates_color
end

#dates_fontObject (readonly)

Returns the value of attribute dates_font.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def dates_font
  @dates_font
end

#dates_formatterObject (readonly)

Returns the value of attribute dates_formatter.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def dates_formatter
  @dates_formatter
end

#dates_height_ratioObject (readonly)

Returns the value of attribute dates_height_ratio.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def dates_height_ratio
  @dates_height_ratio
end

#layer_datesObject (readonly)

Returns the value of attribute layer_dates.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def layer_dates
  @layer_dates
end

#layer_legendObject (readonly)

Returns the value of attribute layer_legend.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def layer_legend
  @layer_legend
end

#layer_marksObject (readonly)

Returns the value of attribute layer_marks.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def layer_marks
  @layer_marks
end

#layer_numbersObject (readonly)

Returns the value of attribute layer_numbers.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def layer_numbers
  @layer_numbers
end

#layer_timelineObject (readonly)

Returns the value of attribute layer_timeline.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def layer_timeline
  @layer_timeline
end

#layer_titleObject (readonly)

Returns the value of attribute layer_title.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def layer_title
  @layer_title
end

#legend_charsObject (readonly)

Returns the value of attribute legend_chars.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def legend_chars
  @legend_chars
end

#legend_colorsObject (readonly)

Returns the value of attribute legend_colors.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def legend_colors
  @legend_colors
end

#legend_fontObject (readonly)

Returns the value of attribute legend_font.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def legend_font
  @legend_font
end

#legend_shapeObject (readonly)

Returns the value of attribute legend_shape.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def legend_shape
  @legend_shape
end

#legend_text_colorObject (readonly)

Returns the value of attribute legend_text_color.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def legend_text_color
  @legend_text_color
end

#legend_titlesObject (readonly)

Returns the value of attribute legend_titles.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def legend_titles
  @legend_titles
end

#marksObject (readonly)

Returns the value of attribute marks.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def marks
  @marks
end

#marks_colorObject (readonly)

Returns the value of attribute marks_color.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def marks_color
  @marks_color
end

#marks_fontObject (readonly)

Returns the value of attribute marks_font.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def marks_font
  @marks_font
end

#marks_formatterObject (readonly)

Returns the value of attribute marks_formatter.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def marks_formatter
  @marks_formatter
end

#marks_height_ratioObject (readonly)

Returns the value of attribute marks_height_ratio.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def marks_height_ratio
  @marks_height_ratio
end

#numbers_colorObject (readonly)

Returns the value of attribute numbers_color.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def numbers_color
  @numbers_color
end

#numbers_fontObject (readonly)

Returns the value of attribute numbers_font.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def numbers_font
  @numbers_font
end

#numbers_formatterObject (readonly)

Returns the value of attribute numbers_formatter.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def numbers_formatter
  @numbers_formatter
end

#rules_colorObject (readonly)

Returns the value of attribute rules_color.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def rules_color
  @rules_color
end

#rules_countObject (readonly)

Returns the value of attribute rules_count.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def rules_count
  @rules_count
end

#threshold_captionObject (readonly)

Returns the value of attribute threshold_caption.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def threshold_caption
  @threshold_caption
end

#threshold_colorObject (readonly)

Returns the value of attribute threshold_color.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def threshold_color
  @threshold_color
end

#threshold_numberObject (readonly)

Returns the value of attribute threshold_number.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def threshold_number
  @threshold_number
end

#threshold_widthObject (readonly)

Returns the value of attribute threshold_width.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def threshold_width
  @threshold_width
end

#timeline_width_ratioObject (readonly)

Returns the value of attribute timeline_width_ratio.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def timeline_width_ratio
  @timeline_width_ratio
end

#title_colorObject (readonly)

Returns the value of attribute title_color.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def title_color
  @title_color
end

#title_fontObject (readonly)

Returns the value of attribute title_font.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def title_font
  @title_font
end

#title_textObject (readonly)

Returns the value of attribute title_text.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def title_text
  @title_text
end

#weekend_bar_colorObject (readonly)

Returns the value of attribute weekend_bar_color.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def weekend_bar_color
  @weekend_bar_color
end

#y_scale_maxObject (readonly)

Returns the value of attribute y_scale_max.



39
40
41
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 39

def y_scale_max
  @y_scale_max
end

Instance Method Details

#dates_heightObject



154
155
156
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 154

def dates_height
  inner_box_height * dates_height_ratio
end

#dates_widthObject



150
151
152
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 150

def dates_width
  timeline_width
end

#legend_heightObject



178
179
180
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 178

def legend_height
  legend_titles.any? ? dates_height : 0
end

#legend_widthObject



174
175
176
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 174

def legend_width
  timeline_width
end

#marks_heightObject



158
159
160
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 158

def marks_height
  inner_box_height * marks_height_ratio
end

#marks_widthObject



162
163
164
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 162

def marks_width
  timeline_width
end

#numbers_heightObject



138
139
140
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 138

def numbers_height
  timeline_height
end

#numbers_widthObject



134
135
136
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 134

def numbers_width
  inner_box_width - timeline_width
end

#timeline_heightObject



170
171
172
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 170

def timeline_height
  inner_box_height - dates_height - legend_height - marks_height
end

#timeline_widthObject



166
167
168
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 166

def timeline_width
  inner_box_width * timeline_width_ratio
end

#title_heightObject



146
147
148
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 146

def title_height
  dates_height
end

#title_widthObject



142
143
144
# File 'lib/rubyvis_charts/abstract_timeline_chart.rb', line 142

def title_width
  numbers_width
end