Class: ChartJS::Point

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

Instance Method Summary collapse

Constructor Details

#initialize(container) ⇒ Point

Returns a new instance of Point.



8
9
10
# File 'lib/chart_js/chart/dataset/point.rb', line 8

def initialize(container)
  @container = container
end

Instance Method Details

#border(&block) ⇒ Object



21
22
23
# File 'lib/chart_js/chart/dataset/point.rb', line 21

def border(&block)
  @container = PointBorder.new(@container).build(&block) 
end

#build(&block) ⇒ Object



12
13
14
15
# File 'lib/chart_js/chart/dataset/point.rb', line 12

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

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



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/chart_js/chart/dataset/point.rb', line 41

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

#hit_radius(value) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/chart_js/chart/dataset/point.rb', line 33

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

#hover(&block) ⇒ Object



17
18
19
# File 'lib/chart_js/chart/dataset/point.rb', line 17

def hover(&block)
  @container = PointHover.new(@container).build(&block) 
end

#radius(value) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/chart_js/chart/dataset/point.rb', line 25

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