Class: Rawbotz::ChartMonthDataset

Inherits:
Object
  • Object
show all
Defined in:
lib/rawbotz/chart_month_dataset.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(date, value, length, darkness) ⇒ ChartMonthDataset

Returns a new instance of ChartMonthDataset.



4
5
6
7
8
9
# File 'lib/rawbotz/chart_month_dataset.rb', line 4

def initialize date, value, length, darkness
  @date   = date
  @value  = value
  @length = length
  @darkness = darkness
end

Instance Attribute Details

#darknessObject

Returns the value of attribute darkness.



3
4
5
# File 'lib/rawbotz/chart_month_dataset.rb', line 3

def darkness
  @darkness
end

#dateObject

Returns the value of attribute date.



3
4
5
# File 'lib/rawbotz/chart_month_dataset.rb', line 3

def date
  @date
end

#lengthObject

Returns the value of attribute length.



3
4
5
# File 'lib/rawbotz/chart_month_dataset.rb', line 3

def length
  @length
end

#valueObject

Returns the value of attribute value.



3
4
5
# File 'lib/rawbotz/chart_month_dataset.rb', line 3

def value
  @value
end

Instance Method Details

#to_sObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rawbotz/chart_month_dataset.rb', line 11

def to_s
  monthname = Date::MONTHNAMES[@date.month]
  <<-eos
  {
  label: "Sales #{monthname[0..2]} #{@date.year}",
  fill: true,
  lineTension: 0.2,
  backgroundColor: "rgba(175,155,155,0)",
  borderColor: "rgba(35,42,102,#{@darkness})",
  borderCapStyle: 'round',
  pointBorderColor: "rgba(0,0,0,#{@darkness})",
  pointBackgroundColor: "#fff",
  pointBorderWidth: 1,
  pointHoverRadius: 8,
  pointHoverBackgroundColor: "rgba(99,102,152,1)",
  pointHoverBorderColor: "rgba(210,210,210,1)",
  pointHoverBorderWidth: 2,
  pointRadius: 2,
  pointHitRadius: 10,
  data : [#{([@value] * @length).join(',')}]
  },
  eos
  #/*data : [#{plot_data.values.map{|v| v[:stock].to_i}.join(',')}]*/
end