pizza_chart 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graph.rb +40 -12
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 912e81fd3f0f4bc420eddc8d14e5bb96dc2ee461
4
- data.tar.gz: acd2db696dfd6016efcc3376e3e9575328b210cf
3
+ metadata.gz: bd45d8bdb41752c92e4a761d62778acfe2f46247
4
+ data.tar.gz: 279852523b2a15ef4c0233ba9039a2001ac0e1e1
5
5
  SHA512:
6
- metadata.gz: c85e4f327e50c6cc538440cbb0b7707aa3c3711abd5c046c9204bdbe8859d62e09701170e77de3a9589938dc87131a0f2c29e68a8e666e39d6016406cadb3e64
7
- data.tar.gz: 9516c7e4432f3b20eaefdde00e9bc3eb2f4b54d33053d1c8094e23b5c7e498b1e4eb7986308b54459f742f96737f42e9c4ee9a79ae95c73d9151a08a3c0e61ae
6
+ metadata.gz: 4fa08219a60e62aea6d058ef859d3328b2fd895e51f44d1a6f95434df4764ffaad0b3e8fe8e0ed708fc6694c33816f9d11eb0583156af737f457be86ffd98921
7
+ data.tar.gz: 9a060803b8246390877d72535b8495b0e79b2c4ff98a804ef8e6bc2b2a8bc6658be7d2a05930c62064671e94421dba67ccf744338d6c7b43e65d100511827cd1
data/lib/graph.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'lazy_high_charts'
2
2
  module Charting
3
- def self.line(x_name, y_data_1, y_name_1, y_data_2, y_name_2, chart_type)
3
+ def self.multichart(x_name, y_data_1, y_name_1, y_data_2, y_name_2, chart_type)
4
4
  if (chart_type) then
5
5
  case chart_type
6
6
  when "pie"
@@ -19,9 +19,33 @@ module Charting
19
19
  f.title({ :text=>"Combination chart"})
20
20
  f.options[:xAxis][:categories] = x_name
21
21
  f.labels(:items=>[:html=> y_name_1 + " VS " + y_name_2, :style=>{:left=>"40px", :top=>"8px", :color=>"black"} ])
22
- f.series(:type=> 'column',:name=> y_name_1,:data=> y_data_1)
23
- f.series(:type=> 'column',:name=> y_name_2,:data=> y_data_2, :center=> [100, 80], :size=> 100, :showInLegend=> true)
24
- puts (instance_of(@chart))
22
+ f.series(:type=> h,:name=> y_name_1,:data=> y_data_1)
23
+ f.series(:type=> h,:name=> y_name_2,:data=> y_data_2, :center=> [100, 80], :size=> 100, :showInLegend=> true)
24
+ #puts (instance_of(@chart))
25
+ end
26
+ end
27
+
28
+ def self.singlechart(x_name, y_data_1, y_name_1, chart_type)
29
+ if (chart_type) then
30
+ case chart_type
31
+ when "pie"
32
+ h='pie'
33
+ when "bar"
34
+ h='bar'
35
+ when "line"
36
+ h='line'
37
+ when "spline"
38
+ h='spline'
39
+ end
40
+ else
41
+ h = 'bar'
42
+ end
43
+ @chart = LazyHighCharts::HighChart.new('graph') do |f|
44
+ f.title({ :text=>"Combination chart"})
45
+ f.options[:xAxis][:categories] = x_name
46
+ f.labels(:items=>[:html=> y_name_1 + " VS " + y_name_2, :style=>{:left=>"40px", :top=>"8px", :color=>"black"} ])
47
+ f.series(:type=> h,:name=> y_name_1,:data=> y_data_1)
48
+ #puts (instance_of(@chart))
25
49
  end
26
50
  end
27
51
 
@@ -46,14 +70,18 @@ module Charting
46
70
  h = 'bar'
47
71
  end
48
72
  @chart = LazyHighCharts::HighChart.new('graph') do |f|
49
- f.title({ :text=>"Combination chart"})
50
- f.options[:xAxis][:categories] = ['Apples', 'Oranges', 'Pears', 'Bananas', 'Plums']
51
- f.labels(:items=>[:html=>"Total fruit consumption", :style=>{:left=>"40px", :top=>"8px", :color=>"black"} ])
52
- f.series(:type=> 'column',:name=> 'Jane',:data=> [3, 2, 1, 3, 4])
53
- f.series(:type=> 'column',:name=> 'John',:data=> [2, 3, 5, 7, 6])
54
- f.series(:type=> 'column', :name=> 'Joe',:data=> [4, 3, 3, 9, 0])
55
- f.series(:type=> 'column', :name=> 'Joe',:data=> [4, 3, 3, 9, 0])
56
- f.series(:type=> 'spline',:name=> 'Average', :data=> [3, 2.67, 3, 6.33, 3.33])
73
+ f.title(text: y_name_1 + " VS "+ y_name_2)
74
+ f.xAxis(categories: x_name)
75
+ f.series(name: y_name_1, yAxis: 0, data: y_data_1)
76
+ f.series(name: y_name_2, yAxis: 1, data: y_data_2)
77
+
78
+ f.yAxis [
79
+ {title: {text: y_name_1, margin: 70} },
80
+ {title: {text: y_name_2}, opposite: true},
81
+ ]
82
+
83
+ f.legend(align: 'right', verticalAlign: 'top', y: 75, x: -50, layout: 'vertical')
84
+ f.chart({defaultSeriesType: "column"})
57
85
  end
58
86
  end
59
87
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pizza_chart
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - 'Kishore Kumar '