Module: NciProjectPizza

Defined in:
lib/nci_project_pizza.rb,
lib/nci_project_pizza/version.rb

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.function_chart(x_name, y_data_1, y_name_1, y_data_2, y_name_2) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/nci_project_pizza.rb', line 16

def self.function_chart(x_name, y_data_1, y_name_1, y_data_2, y_name_2)
    #x_name = "Actual Price"
    #y_name = "Offer Price"
    #x_axis_variables = x_array
    #y_axis_variables = y_array
    #food_name = Food.select("foodName").group_by{|o| o.foodName}.keys
      @chart = LazyHighCharts::HighChart.new('graph') do |f|
          f.title(text: y_name_1 + " VS "+ y_name_2)
          f.xAxis(categories: x_name)
          f.series(name: y_name_1, yAxis: 0, data: x_data_1)
          f.series(name: y_name_2, yAxis: 1, data: y_data_2)

          f.yAxis [
              {title: {text: y_name_1, margin: 70} },
              {title: {text: y_name_2}, opposite: true},
          ]

          f.legend(align: 'right', verticalAlign: 'top', y: 75, x: -50, layout: 'vertical')
          f.chart({defaultSeriesType: "column"})
      end
      return @chart
end

.function_chart_globalObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/nci_project_pizza.rb', line 39

def self.function_chart_global
      @chart_globals = LazyHighCharts::HighChartGlobals.new do |f|
              f.global(useUTC: false)
              f.chart(
                backgroundColor: {
                  linearGradient: [0, 0, 500, 500],
                  stops: [
                    [0, "rgb(255, 255, 255)"],
                    [1, "rgb(240, 240, 255)"]
                  ]
                },
                borderWidth: 2,
                plotBackgroundColor: "rgba(255, 255, 255, .9)",
                plotShadow: true,
                plotBorderWidth: 1
              )
              f.lang(thousandsSep: ",")
              f.colors(["#90ed7d", "#f7a35c", "#8085e9", "#f15c80", "#e4d354"])
      end
      return @chart_globals
end

.graph_multiObj(data_obj1, data_obj2) ⇒ Object



10
11
12
13
14
# File 'lib/nci_project_pizza.rb', line 10

def self.graph_multiObj(data_obj1, data_obj2)
  self.obj1 = Array.new(data_obj1.keys)
  self.obj2 = Array.new(data_obj2.keys)
  return function(obj1, obj2)
end

.graph_singleObj(data_obj) ⇒ Object



5
6
7
8
# File 'lib/nci_project_pizza.rb', line 5

def self.graph_singleObj(data_obj)
  self.obj1 = Array.new(data_obj.keys)
  return function(obj1)
end