gruff 0.11.0-java → 0.14.0-java
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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +66 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +24 -8
- data/.rubocop_todo.yml +57 -53
- data/CHANGELOG.md +34 -0
- data/README.md +15 -7
- data/assets/fonts/LICENSE.txt +202 -0
- data/assets/fonts/Roboto-Bold.ttf +0 -0
- data/assets/fonts/Roboto-Regular.ttf +0 -0
- data/gruff.gemspec +8 -5
- data/lib/gruff.rb +9 -3
- data/lib/gruff/accumulator_bar.rb +3 -3
- data/lib/gruff/area.rb +5 -12
- data/lib/gruff/bar.rb +43 -47
- data/lib/gruff/base.rb +267 -146
- data/lib/gruff/bezier.rb +4 -10
- data/lib/gruff/bullet.rb +13 -19
- data/lib/gruff/dot.rb +14 -19
- data/lib/gruff/font.rb +39 -0
- data/lib/gruff/helper/bar_conversion.rb +28 -13
- data/lib/gruff/helper/bar_value_label.rb +68 -0
- data/lib/gruff/helper/stacked_mixin.rb +1 -2
- data/lib/gruff/histogram.rb +9 -8
- data/lib/gruff/line.rb +59 -56
- data/lib/gruff/mini/bar.rb +10 -7
- data/lib/gruff/mini/legend.rb +19 -10
- data/lib/gruff/mini/pie.rb +10 -8
- data/lib/gruff/mini/side_bar.rb +10 -8
- data/lib/gruff/net.rb +13 -20
- data/lib/gruff/patch/rmagick.rb +22 -24
- data/lib/gruff/patch/string.rb +7 -4
- data/lib/gruff/pie.rb +24 -70
- data/lib/gruff/renderer/bezier.rb +11 -11
- data/lib/gruff/renderer/circle.rb +11 -11
- data/lib/gruff/renderer/dash_line.rb +12 -12
- data/lib/gruff/renderer/dot.rb +16 -16
- data/lib/gruff/renderer/ellipse.rb +11 -11
- data/lib/gruff/renderer/line.rb +12 -12
- data/lib/gruff/renderer/polygon.rb +13 -13
- data/lib/gruff/renderer/polyline.rb +11 -11
- data/lib/gruff/renderer/rectangle.rb +9 -9
- data/lib/gruff/renderer/renderer.rb +23 -50
- data/lib/gruff/renderer/text.rb +32 -29
- data/lib/gruff/scatter.rb +52 -76
- data/lib/gruff/scene.rb +15 -14
- data/lib/gruff/side_bar.rb +49 -52
- data/lib/gruff/side_stacked_bar.rb +29 -20
- data/lib/gruff/spider.rb +13 -22
- data/lib/gruff/stacked_area.rb +10 -16
- data/lib/gruff/stacked_bar.rb +29 -18
- data/lib/gruff/store/{base_data.rb → basic_data.rb} +5 -7
- data/lib/gruff/store/custom_data.rb +4 -6
- data/lib/gruff/store/store.rb +9 -12
- data/lib/gruff/store/xy_data.rb +6 -7
- data/lib/gruff/themes.rb +6 -6
- data/lib/gruff/version.rb +1 -1
- data/rails_generators/gruff/templates/controller.rb +1 -1
- metadata +24 -14
- data/.travis.yml +0 -26
- data/Rakefile +0 -47
- data/assets/plastik/blue.png +0 -0
- data/assets/plastik/green.png +0 -0
- data/assets/plastik/red.png +0 -0
- data/docker/Dockerfile +0 -14
- data/docker/build.sh +0 -4
- data/docker/launch.sh +0 -4
- data/lib/gruff/helper/bar_value_label_mixin.rb +0 -30
- data/lib/gruff/photo_bar.rb +0 -97
data/lib/gruff/version.rb
CHANGED
|
@@ -26,7 +26,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
|
26
26
|
|
|
27
27
|
g.labels = {0 => '2004', 2 => '2005', 4 => '2006'}
|
|
28
28
|
|
|
29
|
-
send_data(g.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "gruff.png")
|
|
29
|
+
send_data(g.to_image.to_blob, :disposition => 'inline', :type => 'image/png', :filename => "gruff.png")
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gruff
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.14.0
|
|
5
5
|
platform: java
|
|
6
6
|
authors:
|
|
7
7
|
- Geoffrey Grosenbach
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2021-07-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -67,6 +67,20 @@ dependencies:
|
|
|
67
67
|
- - ">="
|
|
68
68
|
- !ruby/object:Gem::Version
|
|
69
69
|
version: '0'
|
|
70
|
+
- !ruby/object:Gem::Dependency
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
name: simplecov
|
|
77
|
+
type: :development
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - ">="
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: '0'
|
|
70
84
|
- !ruby/object:Gem::Dependency
|
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
|
72
86
|
requirements:
|
|
@@ -90,22 +104,18 @@ extra_rdoc_files: []
|
|
|
90
104
|
files:
|
|
91
105
|
- ".editorconfig"
|
|
92
106
|
- ".github/ISSUE_TEMPLATE.md"
|
|
107
|
+
- ".github/workflows/ci.yml"
|
|
93
108
|
- ".gitignore"
|
|
94
109
|
- ".rubocop.yml"
|
|
95
110
|
- ".rubocop_todo.yml"
|
|
96
|
-
- ".travis.yml"
|
|
97
111
|
- ".yardopts"
|
|
98
112
|
- CHANGELOG.md
|
|
99
113
|
- Gemfile
|
|
100
114
|
- MIT-LICENSE
|
|
101
115
|
- README.md
|
|
102
|
-
-
|
|
103
|
-
- assets/
|
|
104
|
-
- assets/
|
|
105
|
-
- assets/plastik/red.png
|
|
106
|
-
- docker/Dockerfile
|
|
107
|
-
- docker/build.sh
|
|
108
|
-
- docker/launch.sh
|
|
116
|
+
- assets/fonts/LICENSE.txt
|
|
117
|
+
- assets/fonts/Roboto-Bold.ttf
|
|
118
|
+
- assets/fonts/Roboto-Regular.ttf
|
|
109
119
|
- gruff.gemspec
|
|
110
120
|
- init.rb
|
|
111
121
|
- lib/gruff.rb
|
|
@@ -116,8 +126,9 @@ files:
|
|
|
116
126
|
- lib/gruff/bezier.rb
|
|
117
127
|
- lib/gruff/bullet.rb
|
|
118
128
|
- lib/gruff/dot.rb
|
|
129
|
+
- lib/gruff/font.rb
|
|
119
130
|
- lib/gruff/helper/bar_conversion.rb
|
|
120
|
-
- lib/gruff/helper/
|
|
131
|
+
- lib/gruff/helper/bar_value_label.rb
|
|
121
132
|
- lib/gruff/helper/stacked_mixin.rb
|
|
122
133
|
- lib/gruff/histogram.rb
|
|
123
134
|
- lib/gruff/line.rb
|
|
@@ -128,7 +139,6 @@ files:
|
|
|
128
139
|
- lib/gruff/net.rb
|
|
129
140
|
- lib/gruff/patch/rmagick.rb
|
|
130
141
|
- lib/gruff/patch/string.rb
|
|
131
|
-
- lib/gruff/photo_bar.rb
|
|
132
142
|
- lib/gruff/pie.rb
|
|
133
143
|
- lib/gruff/renderer/bezier.rb
|
|
134
144
|
- lib/gruff/renderer/circle.rb
|
|
@@ -148,7 +158,7 @@ files:
|
|
|
148
158
|
- lib/gruff/spider.rb
|
|
149
159
|
- lib/gruff/stacked_area.rb
|
|
150
160
|
- lib/gruff/stacked_bar.rb
|
|
151
|
-
- lib/gruff/store/
|
|
161
|
+
- lib/gruff/store/basic_data.rb
|
|
152
162
|
- lib/gruff/store/custom_data.rb
|
|
153
163
|
- lib/gruff/store/store.rb
|
|
154
164
|
- lib/gruff/store/xy_data.rb
|
|
@@ -169,7 +179,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
169
179
|
requirements:
|
|
170
180
|
- - ">="
|
|
171
181
|
- !ruby/object:Gem::Version
|
|
172
|
-
version:
|
|
182
|
+
version: 2.4.0
|
|
173
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
184
|
requirements:
|
|
175
185
|
- - ">="
|
data/.travis.yml
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
dist: bionic
|
|
3
|
-
cache: bundler
|
|
4
|
-
|
|
5
|
-
rvm:
|
|
6
|
-
- 2.3
|
|
7
|
-
- 2.4
|
|
8
|
-
- 2.5
|
|
9
|
-
- 2.6
|
|
10
|
-
- 2.7
|
|
11
|
-
- jruby-1.7.27
|
|
12
|
-
- jruby-9.0.5.0
|
|
13
|
-
- jruby-9.1.17.0
|
|
14
|
-
- jruby-9.2.11.1
|
|
15
|
-
|
|
16
|
-
jobs:
|
|
17
|
-
include:
|
|
18
|
-
- name: 'Lint'
|
|
19
|
-
rvm: 2.3
|
|
20
|
-
script: bundle exec rubocop
|
|
21
|
-
|
|
22
|
-
addons:
|
|
23
|
-
apt:
|
|
24
|
-
packages:
|
|
25
|
-
- gsfonts
|
|
26
|
-
- ghostscript
|
data/Rakefile
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'bundler/gem_tasks'
|
|
4
|
-
require 'rake/testtask'
|
|
5
|
-
require 'rake/clean'
|
|
6
|
-
|
|
7
|
-
CLEAN.concat %w[pkg test/output/*]
|
|
8
|
-
|
|
9
|
-
desc 'Run tests'
|
|
10
|
-
task default: :test
|
|
11
|
-
|
|
12
|
-
task gem: :build
|
|
13
|
-
|
|
14
|
-
Rake::TestTask.new
|
|
15
|
-
|
|
16
|
-
namespace :test do
|
|
17
|
-
desc 'Run mini tests'
|
|
18
|
-
task mini: :clean do
|
|
19
|
-
Dir['test/test_mini*'].each do |file|
|
|
20
|
-
system "ruby #{file}"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
desc 'Update expected image with output'
|
|
25
|
-
task :"image:update" do
|
|
26
|
-
require 'rmagick'
|
|
27
|
-
require 'fileutils'
|
|
28
|
-
|
|
29
|
-
update_expected_images = lambda do |expect_dir, output_dir|
|
|
30
|
-
Dir.glob("#{output_dir}/*.png") do |output_path|
|
|
31
|
-
file_name = File.basename(output_path)
|
|
32
|
-
expected_path = "#{expect_dir}/#{file_name}"
|
|
33
|
-
|
|
34
|
-
expected_image = Magick::Image.read(expected_path).first
|
|
35
|
-
output_image = Magick::Image.read(output_path).first
|
|
36
|
-
_, error = expected_image.compare_channel(output_image, Magick::PeakAbsoluteErrorMetric)
|
|
37
|
-
|
|
38
|
-
if error != 0.0
|
|
39
|
-
FileUtils.copy(output_path, expected_path)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
update_expected_images.call('test/expected', 'test/output')
|
|
45
|
-
update_expected_images.call('test/expected_java', 'test/output_java')
|
|
46
|
-
end
|
|
47
|
-
end
|
data/assets/plastik/blue.png
DELETED
|
Binary file
|
data/assets/plastik/green.png
DELETED
|
Binary file
|
data/assets/plastik/red.png
DELETED
|
Binary file
|
data/docker/Dockerfile
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
|
data/docker/build.sh
DELETED
data/docker/launch.sh
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# @private
|
|
4
|
-
module Gruff::Base::BarValueLabelMixin
|
|
5
|
-
class BarValueLabel
|
|
6
|
-
attr_accessor :coordinates, :values
|
|
7
|
-
|
|
8
|
-
def initialize(size, bar_width)
|
|
9
|
-
@coordinates = Array.new(size)
|
|
10
|
-
@values = Hash.new(0)
|
|
11
|
-
@bar_width = bar_width
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def prepare_rendering(format)
|
|
15
|
-
@coordinates.each_with_index do |(left_x, left_y, right_x, _right_y), index|
|
|
16
|
-
value = @values[index]
|
|
17
|
-
val = (format || '%.2f') % value
|
|
18
|
-
y = value >= 0 ? left_y - 30 : left_y + 12
|
|
19
|
-
yield left_x + (right_x - left_x) / 2, y, val.commify
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def prepare_sidebar_rendering(format)
|
|
24
|
-
@coordinates.each_with_index do |(_left_x, _left_y, right_x, right_y), index|
|
|
25
|
-
val = (format || '%.2f') % @values[index]
|
|
26
|
-
yield right_x + 40, right_y - @bar_width / 2, val.commify
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
data/lib/gruff/photo_bar.rb
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'gruff/base'
|
|
4
|
-
|
|
5
|
-
# EXPERIMENTAL!
|
|
6
|
-
#
|
|
7
|
-
# Doesn't work yet.
|
|
8
|
-
#
|
|
9
|
-
class Gruff::PhotoBar < Gruff::Base
|
|
10
|
-
# TODO
|
|
11
|
-
#
|
|
12
|
-
# define base and cap in yml
|
|
13
|
-
# allow for image directory to be located elsewhere
|
|
14
|
-
# more exact measurements for bar heights (go all the way to the bottom of the graph)
|
|
15
|
-
# option to tile images instead of use a single image
|
|
16
|
-
# drop base label a few px lower so photo bar graphs can have a base dropping over the lower marker line
|
|
17
|
-
#
|
|
18
|
-
|
|
19
|
-
# The name of a pre-packaged photo-based theme.
|
|
20
|
-
attr_reader :theme
|
|
21
|
-
|
|
22
|
-
# def initialize(target_width=800)
|
|
23
|
-
# super
|
|
24
|
-
# init_photo_bar_graphics()
|
|
25
|
-
# end
|
|
26
|
-
|
|
27
|
-
def draw
|
|
28
|
-
super
|
|
29
|
-
return unless data_given?
|
|
30
|
-
|
|
31
|
-
return # TODO: Remove for further development
|
|
32
|
-
|
|
33
|
-
init_photo_bar_graphics
|
|
34
|
-
|
|
35
|
-
#Draw#define_clip_path()
|
|
36
|
-
#Draw#clip_path(pathname)
|
|
37
|
-
#Draw#composite....with bar graph image OverCompositeOp
|
|
38
|
-
#
|
|
39
|
-
# See also
|
|
40
|
-
#
|
|
41
|
-
# Draw.pattern # define an image to tile as the filling of a draw object
|
|
42
|
-
#
|
|
43
|
-
|
|
44
|
-
# Setup spacing.
|
|
45
|
-
#
|
|
46
|
-
# Columns sit side-by-side.
|
|
47
|
-
spacing_factor = 0.9
|
|
48
|
-
bar_width = store.norm_data[0].color.columns
|
|
49
|
-
|
|
50
|
-
store.norm_data.each_with_index do |data_row, row_index|
|
|
51
|
-
data_row.points.each_with_index do |data_point, point_index|
|
|
52
|
-
data_point = 0 if data_point.nil?
|
|
53
|
-
# Use incremented x and scaled y
|
|
54
|
-
left_x = @graph_left + (bar_width * (row_index + point_index + ((store.length - 1) * point_index)))
|
|
55
|
-
left_y = @graph_top + (@graph_height - data_point * @graph_height) + 1
|
|
56
|
-
right_x = left_x + bar_width * spacing_factor
|
|
57
|
-
right_y = @graph_top + @graph_height - 1
|
|
58
|
-
|
|
59
|
-
bar_image_width = data_row.color.columns
|
|
60
|
-
bar_image_height = right_y.to_f - left_y.to_f
|
|
61
|
-
|
|
62
|
-
# Crop to scale for data
|
|
63
|
-
bar_image = data_row.color.crop(0, 0, bar_image_width, bar_image_height)
|
|
64
|
-
|
|
65
|
-
@d.gravity = Magick::NorthWestGravity
|
|
66
|
-
@d.composite(left_x, left_y, bar_image_width, bar_image_height, bar_image)
|
|
67
|
-
|
|
68
|
-
# Calculate center based on bar_width and current row
|
|
69
|
-
label_center = @graph_left + (store.length * bar_width * point_index) + (store.length * bar_width / 2.0)
|
|
70
|
-
draw_label(label_center, point_index)
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
Gruff::Renderer.finish
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# Return the chosen theme or the default
|
|
78
|
-
def theme
|
|
79
|
-
@theme || 'plastik'
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
protected
|
|
83
|
-
|
|
84
|
-
# Sets up colors with a list of images that will be used.
|
|
85
|
-
# Images should be 340px tall
|
|
86
|
-
def init_photo_bar_graphics
|
|
87
|
-
color_list = []
|
|
88
|
-
theme_dir = File.dirname(__FILE__) + '/../../assets/' + theme
|
|
89
|
-
|
|
90
|
-
Dir.open(theme_dir).each do |file|
|
|
91
|
-
next unless /\.png$/.match(file)
|
|
92
|
-
|
|
93
|
-
color_list << Magick::Image.read("#{theme_dir}/#{file}").first
|
|
94
|
-
end
|
|
95
|
-
@colors = color_list
|
|
96
|
-
end
|
|
97
|
-
end
|