Class: ActiveCharts::XYChart

Inherits:
RectangularChart show all
Defined in:
lib/active_charts/xy_chart.rb

Direct Known Subclasses

LineChart, ScatterPlot

Constant Summary collapse

OFFSET =
6

Constants inherited from RectangularChart

RectangularChart::TOP_LEFT_OFFSET

Constants inherited from Chart

Chart::CSS_CLASSES, Chart::MARGIN

Instance Attribute Summary collapse

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 RectangularChart

#grid_rect_tag

Methods inherited from Chart

#chart_svg_tag, #legend_list_tag, #to_html

Constructor Details

#initialize(collection, options = {}) ⇒ XYChart

Returns a new instance of XYChart.



5
6
7
8
9
10
# File 'lib/active_charts/xy_chart.rb', line 5

def initialize(collection, options = {})
  super
  
  section_calcs
  tick_calcs
end

Instance Attribute Details

#section_heightObject (readonly)

Returns the value of attribute section_height.



12
13
14
# File 'lib/active_charts/xy_chart.rb', line 12

def section_height
  @section_height
end

#section_widthObject (readonly)

Returns the value of attribute section_width.



12
13
14
# File 'lib/active_charts/xy_chart.rb', line 12

def section_width
  @section_width
end

#x_label_yObject (readonly)

Returns the value of attribute x_label_y.



12
13
14
# File 'lib/active_charts/xy_chart.rb', line 12

def x_label_y
  @x_label_y
end

#x_labelsObject (readonly)

Returns the value of attribute x_labels.



12
13
14
# File 'lib/active_charts/xy_chart.rb', line 12

def x_labels
  @x_labels
end

#x_maxObject (readonly)

Returns the value of attribute x_max.



12
13
14
# File 'lib/active_charts/xy_chart.rb', line 12

def x_max
  @x_max
end

#x_minObject (readonly)

Returns the value of attribute x_min.



12
13
14
# File 'lib/active_charts/xy_chart.rb', line 12

def x_min
  @x_min
end

#x_ticksObject (readonly)

Returns the value of attribute x_ticks.



12
13
14
# File 'lib/active_charts/xy_chart.rb', line 12

def x_ticks
  @x_ticks
end

#y_label_xObject (readonly)

Returns the value of attribute y_label_x.



12
13
14
# File 'lib/active_charts/xy_chart.rb', line 12

def y_label_x
  @y_label_x
end

#y_labelsObject (readonly)

Returns the value of attribute y_labels.



12
13
14
# File 'lib/active_charts/xy_chart.rb', line 12

def y_labels
  @y_labels
end

#y_maxObject (readonly)

Returns the value of attribute y_max.



12
13
14
# File 'lib/active_charts/xy_chart.rb', line 12

def y_max
  @y_max
end

#y_minObject (readonly)

Returns the value of attribute y_min.



12
13
14
# File 'lib/active_charts/xy_chart.rb', line 12

def y_min
  @y_min
end

#y_ticksObject (readonly)

Returns the value of attribute y_ticks.



12
13
14
# File 'lib/active_charts/xy_chart.rb', line 12

def y_ticks
  @y_ticks
end

Instance Method Details

#bottom_label_text_tagsObject



23
24
25
26
27
28
29
30
31
# File 'lib/active_charts/xy_chart.rb', line 23

def bottom_label_text_tags
  x_labels.map.with_index do |label, index| 
    label = formatted_val(label, data_formatters[0])
    classes = 'ac-x-label'
    classes += ' anchor_start' if index.zero?
  
    tag.text(label, x: x_tick_x(index), y: x_label_y, class: classes)
  end.join
end

#side_label_text_tagsObject



15
16
17
18
19
20
21
# File 'lib/active_charts/xy_chart.rb', line 15

def side_label_text_tags
  y_labels.map.with_index do |label, index| 
    label = formatted_val(label, data_formatters[1])
    
    tag.text(label, x: y_label_x, y: y_tick_y(index), class: 'ac-y-label')
  end.join
end