Sha256: 7a13405cc0ce8933cec1b198703185447b575edc5cab51a4f7f139e199566c95

Contents?: true

Size: 1.1 KB

Versions: 35

Compression:

Stored size: 1.1 KB

Contents

require_relative 'point_hover.rb'
require_relative 'point_border.rb'

module ChartJS

  class Point 

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

    def hover(&block)
      @container = PointHover.new(@container).build(&block) 
    end
    
    def border(&block)
      @container = PointBorder.new(@container).build(&block) 
    end
    
    def radius(value)
      if value.is_a? Array
        @container['pointRadius'] = value.map(&:to_i) 
      else
        @container['pointRadius'] = value.to_i
      end
    end
    
    def hit_radius(value)
      if value.is_a? Array
        @container['pointHitRadius'] = value.map(&:to_i) 
      else
        @container['pointHitRadius'] = value.to_i
      end
    end

    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
    
  end

end

Version data entries

35 entries across 5 versions & 1 rubygems

Version Path
chart_js-1.1.1 lib/chart_js/chart/bar_chart/dataset/point.rb
chart_js-1.1.1 lib/chart_js/chart/radar_chart/point.rb
chart_js-1.1.1 lib/chart_js/chart/radar_chart/dataset/point.rb
chart_js-1.1.1 lib/chart_js/chart/line_chart/point.rb
chart_js-1.1.1 lib/chart_js/chart/line_chart/dataset/point.rb
chart_js-1.1.1 lib/chart_js/chart/dataset/point.rb
chart_js-1.1.1 lib/chart_js/chart/bar_chart/point.rb
chart_js-1.1.0 lib/chart_js/chart/radar_chart/point.rb
chart_js-1.1.0 lib/chart_js/chart/radar_chart/dataset/point.rb
chart_js-1.1.0 lib/chart_js/chart/line_chart/point.rb
chart_js-1.1.0 lib/chart_js/chart/line_chart/dataset/point.rb
chart_js-1.1.0 lib/chart_js/chart/dataset/point.rb
chart_js-1.1.0 lib/chart_js/chart/bar_chart/point.rb
chart_js-1.1.0 lib/chart_js/chart/bar_chart/dataset/point.rb
chart_js-1.0.0 lib/chart_js/chart/bar_chart/dataset/point.rb
chart_js-1.0.0 lib/chart_js/chart/bar_chart/point.rb
chart_js-1.0.0 lib/chart_js/chart/dataset/point.rb
chart_js-1.0.0 lib/chart_js/chart/line_chart/dataset/point.rb
chart_js-1.0.0 lib/chart_js/chart/line_chart/point.rb
chart_js-1.0.0 lib/chart_js/chart/radar_chart/dataset/point.rb