Class: ChartJS::PointHover

Inherits:
Object
  • Object
show all
Defined in:
lib/chart_js/chart/dataset/point_hover.rb,
lib/chart_js/chart/bar_chart/point_hover.rb,
lib/chart_js/chart/line_chart/point_hover.rb,
lib/chart_js/chart/radar_chart/point_hover.rb,
lib/chart_js/chart/bar_chart/dataset/point_hover.rb,
lib/chart_js/chart/line_chart/dataset/point_hover.rb,
lib/chart_js/chart/radar_chart/dataset/point_hover.rb

Instance Method Summary collapse

Constructor Details

#initialize(container) ⇒ PointHover

Returns a new instance of PointHover.



5
6
7
# File 'lib/chart_js/chart/dataset/point_hover.rb', line 5

def initialize(container)
  @container = container
end

Instance Method Details

#build(&block) ⇒ Object



9
10
11
12
# File 'lib/chart_js/chart/dataset/point_hover.rb', line 9

def build(&block)
  instance_eval(&block)
  @container 
end

#color(value, type = :both) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/chart_js/chart/dataset/point_hover.rb', line 30

def color(value, type = :both)
  case type 
  when :border
    @container['pointHoverBorderColor'] = value
  when :background
    @container['pointHoverBackgroundColor'] = value
  when :both
    color value, :borer
    color value, :background
  end
end

#radius(value) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/chart_js/chart/dataset/point_hover.rb', line 14

def radius(value)
  if value.is_a? Array
    @container['pointHoverRadius'] = value.map(&:to_i) 
  else
    @container['pointHoverRadius'] = value.to_i
  end
end

#width(value) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/chart_js/chart/dataset/point_hover.rb', line 22

def width(value)
  if value.is_a? Array
    @container['pointHoverBorderWidth'] = value.map(&:to_i) 
  else
    @container['pointHoverBorderWidth'] = value.to_i
  end
end