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