class RubyvisCharts::AreaTimelineChart

Constants

LONG_MONTH_DAYS
LONG_MONTH_PADDING

Attributes

areas_colors[R]

Public Class Methods

new( areas_colors: DefaultArguments::AREAS_COLORS, **other ) click to toggle source
# File lib/rubyvis_charts/area_timeline_chart.rb, line 12
def initialize(
  areas_colors: DefaultArguments::AREAS_COLORS,
  **other
)
  super(other)

  @areas_colors = areas_colors

  initialize_areas!
end

Private Instance Methods

initialize_areas!() click to toggle source
# File lib/rubyvis_charts/area_timeline_chart.rb, line 25
def initialize_areas!
  chart = self

  area_left_offset = -> { chart.send(:graph_width).scale(self.index) + chart.send(:graph_width).scale(1)/2 }
  height = ->(d) { chart.send(:bars_heights).scale(d) }

  values.each_with_index do |area, index|
    @layer_timeline.add(Rubyvis::Area)
      .data(area)
      .bottom(0)
      .left(area_left_offset)
      .height(height)
      .fillStyle(areas_colors[index])
  end
end