Class: ActiveCharts::LineChart
- Inherits:
-
XYChart
- Object
- Chart
- RectangularChart
- XYChart
- ActiveCharts::LineChart
- Defined in:
- lib/active_charts/line_chart.rb
Constant Summary
Constants inherited from XYChart
Constants inherited from RectangularChart
RectangularChart::TOP_LEFT_OFFSET
Constants inherited from Chart
Chart::CSS_CLASSES, Chart::MARGIN
Instance Attribute Summary collapse
-
#line_labels ⇒ Object
readonly
Returns the value of attribute line_labels.
Attributes inherited from XYChart
#section_height, #section_width, #x_label_y, #x_labels, #x_max, #x_min, #x_ticks, #y_label_x, #y_labels, #y_max, #y_min, #y_ticks
Attributes inherited from RectangularChart
#grid_height, #grid_width, #svg_height, #svg_width
Attributes inherited from Chart
#collection, #columns_count, #data_formatters, #extra_css_classes, #label_height, #max_values, #rows_count, #series_labels, #title
Instance Method Summary collapse
Methods inherited from XYChart
#bottom_label_text_tags, #initialize, #side_label_text_tags
Methods inherited from RectangularChart
Methods inherited from Chart
#initialize, #legend_list_tag, #to_html
Constructor Details
This class inherits a constructor from ActiveCharts::XYChart
Instance Attribute Details
#line_labels ⇒ Object (readonly)
Returns the value of attribute line_labels.
3 4 5 |
# File 'lib/active_charts/line_chart.rb', line 3 def line_labels @line_labels end |
Instance Method Details
#chart_svg_tag ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/active_charts/line_chart.rb', line 5 def chart_svg_tag inner_html = [grid_rect_tag, ticks(x_ticks, y_ticks), lines, , , ].flatten.join(' ') tag.svg(inner_html.html_safe, ) end |
#dots_specs ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/active_charts/line_chart.rb', line 29 def dots_specs (0..columns_count - 1).map do |col_index| collection.map.with_index do |row, row_index| dot_spec(row[col_index], row_index) end end end |
#line_label_tags ⇒ Object
23 24 25 26 27 |
# File 'lib/active_charts/line_chart.rb', line 23 def dots_specs.flatten.map do |dot| tag.text(dot[:label], x: dot[:cx] + OFFSET, y: dot[:cy] - OFFSET, class: label_classes) end end |
#lines ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/active_charts/line_chart.rb', line 13 def lines dots_specs.map.with_index do |line_dots, index| d = line_dots.map do |dot| [dot[:cx], dot[:cy]].join(' ') end tag.path('', d: 'M' + d.join(' L '), class: line_classes(index)) end end |