gruff 0.8.0-java → 0.9.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +18 -0
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +93 -0
  5. data/.rubocop_todo.yml +23 -810
  6. data/.travis.yml +4 -4
  7. data/.yardopts +1 -0
  8. data/CHANGELOG.md +22 -0
  9. data/Gemfile +3 -1
  10. data/README.md +44 -21
  11. data/Rakefile +2 -206
  12. data/docker/Dockerfile +14 -0
  13. data/docker/build.sh +4 -0
  14. data/docker/launch.sh +4 -0
  15. data/gruff.gemspec +11 -8
  16. data/init.rb +2 -0
  17. data/lib/gruff.rb +23 -0
  18. data/lib/gruff/accumulator_bar.rb +6 -6
  19. data/lib/gruff/area.rb +13 -17
  20. data/lib/gruff/bar.rb +58 -41
  21. data/lib/gruff/base.rb +243 -566
  22. data/lib/gruff/bezier.rb +12 -14
  23. data/lib/gruff/bullet.rb +39 -57
  24. data/lib/gruff/dot.rb +25 -59
  25. data/lib/gruff/{bar_conversion.rb → helper/bar_conversion.rb} +13 -12
  26. data/lib/gruff/helper/bar_value_label_mixin.rb +30 -0
  27. data/lib/gruff/{stacked_mixin.rb → helper/stacked_mixin.rb} +7 -6
  28. data/lib/gruff/line.rb +95 -177
  29. data/lib/gruff/mini/bar.rb +6 -7
  30. data/lib/gruff/mini/legend.rb +16 -32
  31. data/lib/gruff/mini/pie.rb +6 -7
  32. data/lib/gruff/mini/side_bar.rb +4 -5
  33. data/lib/gruff/net.rb +37 -65
  34. data/lib/gruff/patch/rmagick.rb +33 -0
  35. data/lib/gruff/patch/string.rb +8 -0
  36. data/lib/gruff/photo_bar.rb +19 -19
  37. data/lib/gruff/pie.rb +22 -73
  38. data/lib/gruff/renderer/bezier.rb +21 -0
  39. data/lib/gruff/renderer/circle.rb +21 -0
  40. data/lib/gruff/renderer/dash_line.rb +22 -0
  41. data/lib/gruff/renderer/dot.rb +39 -0
  42. data/lib/gruff/renderer/ellipse.rb +21 -0
  43. data/lib/gruff/renderer/line.rb +34 -0
  44. data/lib/gruff/renderer/polygon.rb +23 -0
  45. data/lib/gruff/renderer/polyline.rb +21 -0
  46. data/lib/gruff/renderer/rectangle.rb +19 -0
  47. data/lib/gruff/renderer/renderer.rb +127 -0
  48. data/lib/gruff/renderer/text.rb +42 -0
  49. data/lib/gruff/scatter.rb +85 -156
  50. data/lib/gruff/scene.rb +22 -30
  51. data/lib/gruff/side_bar.rb +62 -58
  52. data/lib/gruff/side_stacked_bar.rb +47 -43
  53. data/lib/gruff/spider.rb +19 -36
  54. data/lib/gruff/stacked_area.rb +17 -21
  55. data/lib/gruff/stacked_bar.rb +50 -24
  56. data/lib/gruff/store/base_data.rb +34 -0
  57. data/lib/gruff/store/custom_data.rb +34 -0
  58. data/lib/gruff/store/store.rb +80 -0
  59. data/lib/gruff/store/xy_data.rb +55 -0
  60. data/lib/gruff/themes.rb +3 -3
  61. data/lib/gruff/version.rb +3 -1
  62. metadata +41 -30
  63. data/Manifest.txt +0 -81
  64. data/assets/bubble.png +0 -0
  65. data/assets/city_scene/background/0000.png +0 -0
  66. data/assets/city_scene/background/0600.png +0 -0
  67. data/assets/city_scene/background/2000.png +0 -0
  68. data/assets/city_scene/clouds/cloudy.png +0 -0
  69. data/assets/city_scene/clouds/partly_cloudy.png +0 -0
  70. data/assets/city_scene/clouds/stormy.png +0 -0
  71. data/assets/city_scene/grass/default.png +0 -0
  72. data/assets/city_scene/haze/true.png +0 -0
  73. data/assets/city_scene/number_sample/1.png +0 -0
  74. data/assets/city_scene/number_sample/2.png +0 -0
  75. data/assets/city_scene/number_sample/default.png +0 -0
  76. data/assets/city_scene/sky/0000.png +0 -0
  77. data/assets/city_scene/sky/0200.png +0 -0
  78. data/assets/city_scene/sky/0400.png +0 -0
  79. data/assets/city_scene/sky/0600.png +0 -0
  80. data/assets/city_scene/sky/0800.png +0 -0
  81. data/assets/city_scene/sky/1000.png +0 -0
  82. data/assets/city_scene/sky/1200.png +0 -0
  83. data/assets/city_scene/sky/1400.png +0 -0
  84. data/assets/city_scene/sky/1500.png +0 -0
  85. data/assets/city_scene/sky/1700.png +0 -0
  86. data/assets/city_scene/sky/2000.png +0 -0
  87. data/assets/pc306715.jpg +0 -0
  88. data/lib/gruff/deprecated.rb +0 -38
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
- sudo: false
2
+ dist: bionic
3
3
  cache: bundler
4
4
 
5
5
  rvm:
@@ -8,10 +8,10 @@ rvm:
8
8
  - 2.5
9
9
  - 2.6
10
10
  - 2.7
11
- - jruby-1.7.26
11
+ - jruby-1.7.27
12
12
  - jruby-9.0.5.0
13
- - jruby-9.1.9.0
14
- - jruby-head
13
+ - jruby-9.1.17.0
14
+ - jruby-9.2.11.1
15
15
 
16
16
  jobs:
17
17
  include:
@@ -0,0 +1 @@
1
+ --no-private
@@ -1,5 +1,27 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.9.0
4
+
5
+ * Fix that sidebar label is not displayed on JRuby platform (#402)
6
+ * Add `group_spacing` which is spacing factor applied between a group of bars belonging to the same label (#400)
7
+ * Fix that label is displayed in the center of the side bar (#399)
8
+ * Fix that value label is displayed in the center of the side bar (#398)
9
+ * Add `show_labels_for_bar_values` into StackedBar (#396)
10
+ * Auto resize title font size if long title will be cut off (#395)
11
+ * Adjust label position in StackedBar (#394)
12
+ * Fix that labels are rendered in the center of bar graph (#393)
13
+ * Remove `stacked` property marked as experimental (#392)
14
+ * Fix to not move away from the baseline if big value was given into `segment_spacing` (#391)
15
+ * Add `segment_spacing property` into SideStackedBar like StackedBar (#390)
16
+ * Fix an exception when using an object as an argument that behaves as an Array (#317)
17
+ * Add `Scatter#dataxy` method like `Line#dataxy` (#316)
18
+ * Retry to fill background to fix "cache resources exhausted" error (#305)
19
+ * Fix label position in Gruff::Bar with negative value (#265)
20
+ * Fixed a bug that did not handle the specified minimum/maximum properly (#260)
21
+ * Fix error of “comparison of Integer with nil failed” (#257, #366, #367)
22
+ * Fix redundant label padding with many decimal points (#254)
23
+ * Fix that value label might be displayed with scientific notation (#252)
24
+
3
25
  ## 0.8.0
4
26
 
5
27
  * Remove version restriction in RMagick (#186)
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
- source 'http://rubygems.org'
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in gruff.gemspec
4
6
  gemspec
data/README.md CHANGED
@@ -12,19 +12,25 @@ for a list of the system-level prerequisities (ImageMagick etc) and how to insta
12
12
 
13
13
  Add this line to your application's Gemfile:
14
14
 
15
- gem 'gruff'
15
+ ```sh
16
+ gem 'gruff'
17
+ ```
16
18
 
17
19
  And then execute:
18
20
 
19
- $ bundle
21
+ ```sh
22
+ $ bundle
23
+ ```
20
24
 
21
25
  Or install it yourself as:
22
26
 
23
- $ gem install gruff
27
+ ```sh
28
+ $ gem install gruff
29
+ ```
24
30
 
25
31
  ## Usage
26
32
 
27
- ```Ruby
33
+ ```ruby
28
34
  require 'gruff'
29
35
  g = Gruff::Line.new
30
36
  g.title = 'Wow! Look at this!'
@@ -43,75 +49,75 @@ g.write('exciting.png')
43
49
 
44
50
  You can find many examples in the [test](https://github.com/topfunky/gruff/tree/master/test)
45
51
  directory along with their resulting charts in the
46
- [output](https://github.com/topfunky/gruff/tree/master/test/output) directory.
52
+ [expected](https://github.com/topfunky/gruff/tree/master/test/expected) directory.
47
53
 
48
54
  ### Accumulator bar chart
49
55
 
50
- ![Accumulator bar chart](https://raw.github.com/topfunky/gruff/master/test/output/accum_bar.png)
56
+ ![Accumulator bar chart](https://raw.github.com/topfunky/gruff/master/test/expected/accum_bar.png)
51
57
 
52
58
  ### Area chart
53
59
 
54
- ![Area chart](https://raw.github.com/topfunky/gruff/master/test/output/area_keynote.png)
60
+ ![Area chart](https://raw.github.com/topfunky/gruff/master/test/expected/area_keynote.png)
55
61
 
56
62
  ### Bar chart
57
63
 
58
- ![Bar chart](https://raw.github.com/topfunky/gruff/master/test/output/bar_rails_keynote.png)
64
+ ![Bar chart](https://raw.github.com/topfunky/gruff/master/test/expected/bar_rails_keynote.png)
59
65
 
60
66
  ### Bezier chart
61
67
 
62
68
  In progress!
63
69
 
64
- ![Bezier chart](https://raw.github.com/topfunky/gruff/master/test/output/bezier_3.png)
70
+ ![Bezier chart](https://raw.github.com/topfunky/gruff/master/test/expected/bezier_3.png)
65
71
 
66
72
  ### Bullet chart
67
73
 
68
74
  In progress!
69
75
 
70
- ![Bullet chart](https://raw.github.com/topfunky/gruff/master/test/output/bullet_greyscale.png)
76
+ ![Bullet chart](https://raw.github.com/topfunky/gruff/master/test/expected/bullet_greyscale.png)
71
77
 
72
78
  ### Dot chart
73
79
 
74
- ![Dot chart](https://raw.github.com/topfunky/gruff/master/test/output/dot.png)
80
+ ![Dot chart](https://raw.github.com/topfunky/gruff/master/test/expected/dot.png)
75
81
 
76
82
  ### Line chart
77
83
 
78
- ![Line chart](https://raw.github.com/topfunky/gruff/master/test/output/line_theme_rails_keynote_.png)
84
+ ![Line chart](https://raw.github.com/topfunky/gruff/master/test/expected/line_theme_rails_keynote_.png)
79
85
 
80
86
  ### LineXY chart
81
87
 
82
- ![LineXY chart](https://raw.github.com/topfunky/gruff/master/test/output/line_xy.png)
88
+ ![LineXY chart](https://raw.github.com/topfunky/gruff/master/test/expected/line_xy.png)
83
89
 
84
90
  ### Net chart
85
91
 
86
- ![Net chart](https://raw.github.com/topfunky/gruff/master/test/output/net_wide_graph.png)
92
+ ![Net chart](https://raw.github.com/topfunky/gruff/master/test/expected/net_wide_graph.png)
87
93
 
88
94
  ### Pie chart
89
95
 
90
- ![Pie chart](https://raw.github.com/topfunky/gruff/master/test/output/pie_pastel.png)
96
+ ![Pie chart](https://raw.github.com/topfunky/gruff/master/test/expected/pie_pastel.png)
91
97
 
92
98
  ### Scatter chart
93
99
 
94
- ![Scatter chart](https://raw.github.com/topfunky/gruff/master/test/output/scatter_basic.png)
100
+ ![Scatter chart](https://raw.github.com/topfunky/gruff/master/test/expected/scatter_basic.png)
95
101
 
96
102
  ### Side bar chart
97
103
 
98
- ![Side bar chart](https://raw.github.com/topfunky/gruff/master/test/output/side_bar.png)
104
+ ![Side bar chart](https://raw.github.com/topfunky/gruff/master/test/expected/side_bar.png)
99
105
 
100
106
  ### Side stacked bar chart
101
107
 
102
- ![Side stacked bar chart](https://raw.github.com/topfunky/gruff/master/test/output/side_stacked_bar_keynote.png)
108
+ ![Side stacked bar chart](https://raw.github.com/topfunky/gruff/master/test/expected/side_stacked_bar_keynote.png)
103
109
 
104
110
  ### Spider chart
105
111
 
106
- ![Spider chart](https://raw.github.com/topfunky/gruff/master/test/output/spider_37signals.png)
112
+ ![Spider chart](https://raw.github.com/topfunky/gruff/master/test/expected/spider_37signals.png)
107
113
 
108
114
  ### Stacked area chart
109
115
 
110
- ![Stacked area chart](https://raw.github.com/topfunky/gruff/master/test/output/stacked_area_keynote.png)
116
+ ![Stacked area chart](https://raw.github.com/topfunky/gruff/master/test/expected/stacked_area_keynote.png)
111
117
 
112
118
  ### Stacked bar chart
113
119
 
114
- ![Stacked bar chart](https://raw.github.com/topfunky/gruff/master/test/output/stacked_bar_keynote.png)
120
+ ![Stacked bar chart](https://raw.github.com/topfunky/gruff/master/test/expected/stacked_bar_keynote.png)
115
121
 
116
122
 
117
123
  ## Documentation
@@ -123,6 +129,23 @@ http://www.rubydoc.info/github/topfunky/gruff/frames
123
129
  We aim to support all Ruby implementations supporting Ruby language level 1.9.3
124
130
  or later. Currently we are running CI for MRI, JRuby, and Rubinius.
125
131
 
132
+ ## Development Setup
133
+ 1. Build docker image
134
+ ```sh
135
+ $ ./docker/build.sh
136
+ ```
137
+
138
+ 2. Launch docker image
139
+ ```sh
140
+ $ ./docker/launch.sh
141
+ ```
142
+
143
+ 3. Run tests
144
+ ```sh
145
+ $ bundle install
146
+ $ bundle exec rake
147
+ ```
148
+
126
149
  ## Contributing
127
150
 
128
151
  ### Source
data/Rakefile CHANGED
@@ -1,4 +1,5 @@
1
- require 'rubygems'
1
+ # frozen_string_literal: true
2
+
2
3
  require 'bundler/gem_tasks'
3
4
  require 'rake/testtask'
4
5
  require 'rake/clean'
@@ -20,208 +21,3 @@ namespace :test do
20
21
  end
21
22
  end
22
23
  end
23
-
24
- desc 'Generate release docs for a given milestone'
25
- task :release_docs do
26
- raise "\n This task requires Ruby 1.9 or newer to parse JSON as YAML.\n\n" if RUBY_VERSION == '1.8.7'
27
-
28
- categories, grouped_issues, milestone, milestone_description, milestone_name = get_github_issues
29
-
30
- puts '=' * 80
31
- puts
32
- release_doc = <<EOF
33
- Subject: [ANN] Gruff #{milestone_name} released!
34
-
35
- The Gruff team is pleased to announce the release of Gruff #{milestone_name}.
36
-
37
- New in version #{milestone_name}:
38
-
39
- #{milestone_description}
40
-
41
- #{(categories.keys & grouped_issues.keys).map do |cat|
42
- "#{cat}:\n
43
- #{grouped_issues[cat].map { |i| wrap(%Q(* Issue ##{i['number']} #{i['title']}), 2) }.join("\n")}
44
- "
45
- end.join("\n")}
46
- You can find a complete list of issues here:
47
-
48
- * https://github.com/topfunky/gruff/issues?state=closed&milestone=#{milestone}
49
-
50
-
51
- Installation:
52
-
53
- gem install gruff
54
-
55
- You can find an introductory tutorial at
56
- https://github.com/topfunky/gruff
57
-
58
- Enjoy!
59
-
60
-
61
- --
62
- The Gruff Team
63
- EOF
64
-
65
- puts release_doc
66
- puts
67
- puts '=' * 80
68
-
69
- unless Gem::Version.new(Gruff::VERSION).prerelease?
70
- File.write('RELEASE.md', release_doc)
71
- end
72
- end
73
-
74
- desc 'Fetch download stats form rubygems.org'
75
- task :stats do
76
- require 'time'
77
- require 'date'
78
- require 'rubygems'
79
- require 'uri'
80
- require 'net/http'
81
- require 'net/https'
82
- require 'openssl'
83
- require 'yaml'
84
- host = 'rubygems.org'
85
- base_uri = "https://#{host}/api/v1"
86
- https = Net::HTTP.new(host, 443)
87
- https.use_ssl = true
88
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
89
-
90
- counts_per_month = Hash.new { |h, k| h[k] = Hash.new { |mh, mk| mh[mk] = 0 } }
91
- total = 0
92
-
93
- %w[gruff].each do |gem|
94
- versions_uri = URI("#{base_uri}/versions/#{gem}.yaml")
95
- req = Net::HTTP::Get.new(versions_uri.request_uri)
96
- res = https.start { |http| http.request(req) }
97
- versions = YAML.load(res.body).sort_by { |v| Gem::Version.new(v['number']) }
98
- puts "\n#{gem}:\n#{versions.map { |v| "#{Time.parse(v['built_at']).strftime('%Y-%m-%d')} #{'%10s' % v['number']} #{v['downloads_count']}" }.join("\n")}"
99
-
100
- versions.each do |v|
101
- downloads_uri = URI("#{base_uri}/versions/#{gem}-#{v['number']}/downloads/search.yaml?from=#{Time.parse(v['built_at']).strftime('%Y-%m-%d')}&to=#{Date.today}")
102
- req = Net::HTTP::Get.new(downloads_uri.request_uri)
103
- res = https.start { |http| http.request(req) }
104
- counts = YAML.load(res.body)
105
- counts.delete_if { |date_str, count| count == 0 }
106
- counts.each do |date_str, count|
107
- date = Date.parse(date_str)
108
- counts_per_month[date.year][date.month] += count
109
- total += count
110
- end
111
- print '.'
112
- STDOUT.flush
113
- end
114
- puts
115
- end
116
-
117
- puts "\nDownloads statistics per month:"
118
- years = counts_per_month.keys
119
- puts "\n #{years.map { |year| '%6s:' % year }.join(' ')}"
120
- (1..12).each do |month|
121
- print "#{'%2d' % month}:"
122
- years.each do |year|
123
- count = counts_per_month[year][month]
124
- print count > 0 ? '%8d' % count : ' ' * 8
125
- end
126
- puts
127
- end
128
-
129
- puts "\nTotal: #{total}\n\n"
130
-
131
- puts "\nRubyGems download statistics per month:"
132
- years = counts_per_month.keys
133
- puts ' ' + years.map { |year| '%-12s' % year }.join
134
- (0..20).each do |l|
135
- print (l % 10 == 0) ? '%4d' % ((20 - l) * 100) : ' '
136
- years.each do |year|
137
- (1..12).each do |month|
138
- count = counts_per_month[year][month]
139
- if [year, month] == [Date.today.year, Date.today.month]
140
- count *= (Date.new(Date.today.year, Date.today.month, -1).day.to_f / Date.today.day).to_i
141
- end
142
- print count > ((20 - l) * 100) ? '*' : ' '
143
- end
144
- end
145
- puts
146
- end
147
- puts ' ' + years.map { |year| '%-12s' % year }.join
148
-
149
- puts "\nTotal: #{total}\n\n"
150
- end
151
-
152
- def get_github_issues
153
- puts 'GitHub login:'
154
- begin
155
- require 'rubygems'
156
- require 'highline/import'
157
- user = ask('login : ') { |q| q.echo = true }
158
- pass = ask('password: ') { |q| q.echo = '*' }
159
- rescue Exception
160
- print 'user name: '
161
- user = STDIN.gets.chomp
162
-
163
- print ' password: '
164
- pass = STDIN.gets.chomp
165
- end
166
- require 'uri'
167
- require 'net/http'
168
- require 'net/https'
169
- require 'openssl'
170
- require 'yaml'
171
- host = 'api.github.com'
172
- base_uri = "https://#{host}/repos/topfunky/gruff"
173
- https = Net::HTTP.new(host, 443)
174
- https.use_ssl = true
175
- https.verify_mode = OpenSSL::SSL::VERIFY_NONE
176
-
177
- milestone_uri = URI("#{base_uri}/milestones")
178
- req = Net::HTTP::Get.new(milestone_uri.request_uri)
179
- req.basic_auth(user, pass)
180
- res = https.start { |http| http.request(req) }
181
- milestones = YAML.load(res.body).sort_by { |i| Date.parse(i['due_on']) }
182
- puts milestones.map { |m| "#{'%2d' % m['number']} #{m['title']}" }.join("\n")
183
-
184
- if defined? ask
185
- milestone = ask('milestone: ', Integer) { |q| q.echo = true }
186
- else
187
- print 'milestone: '
188
- milestone = STDIN.gets.chomp
189
- end
190
-
191
- uri = URI("#{base_uri}/issues?milestone=#{milestone}&state=closed&per_page=1000")
192
- req = Net::HTTP::Get.new(uri.request_uri)
193
- req.basic_auth(user, pass)
194
- res = https.start { |http| http.request(req) }
195
- issues = YAML.load(res.body).sort_by { |i| i['number'] }
196
- milestone_name = issues[0] ? issues[0]['milestone']['title'] : "No issues for milestone #{milestone}"
197
- milestone_description = issues[0] ? issues[0]['milestone']['description'] : "No issues for milestone #{milestone}"
198
- milestone_description = milestone_description.split("\r\n").map { |l| wrap l }.join("\r\n")
199
- categories = {
200
- 'Features' => 'feature',
201
- 'Bugfixes' => 'bug',
202
- 'Support' => 'support',
203
- 'Documentation' => 'documentation',
204
- 'Pull requests' => nil,
205
- 'Internal' => 'internal',
206
- 'Rejected' => 'rejected',
207
- 'Other' => nil
208
- }
209
- grouped_issues = issues.group_by do |i|
210
- labels = i['labels'].map { |l| l['name'] }
211
- cat = nil
212
- categories.each do |k, v|
213
- if labels.include? v
214
- cat = k
215
- break
216
- end
217
- end
218
- cat ||= i['pull_request'] && i['pull_request']['html_url'] && 'Pull requests'
219
- cat ||= 'Other'
220
- cat
221
- end
222
- return categories, grouped_issues, milestone, milestone_description, milestone_name
223
- end
224
-
225
- def wrap(string, indent = 0)
226
- string.scan(/\S.{0,72}\S(?=\s|$)|\S+/).join("\n" + ' ' * indent)
227
- end
@@ -0,0 +1,14 @@
1
+ FROM ubuntu:18.04
2
+
3
+ RUN apt update && apt install -y gcc libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev \
4
+ libmagickwand-dev wget git pkg-config && \
5
+ wget https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.gz && \
6
+ tar xvzf ruby-2.7.1.tar.gz && \
7
+ cd ruby-2.7.1 && \
8
+ ./configure --prefix=/usr --disable-install-rdoc && \
9
+ make -j install && \
10
+ cd .. && rm -rf ruby-2.7.1 && \
11
+ gem install bundler -v 1.17.3 && \
12
+ /usr/bin/bundle config set --local path 'vendor/bundle'
13
+
14
+ WORKDIR /opt/gruff
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ script_dir=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
4
+ docker build -t gruff ${script_dir}
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ prject_dir="$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)/.."
4
+ docker run -v $prject_dir:/opt/gruff --rm -it gruff bash