svg-graph 2.1.2 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +7 -0
- data/lib/SVG/Graph/Pie.rb +38 -39
- data/lib/svggraph.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e90898ce4dcd05963231c3079d62310773f6d5fd
|
4
|
+
data.tar.gz: 8a3008024055118d688581ff05b09e572d78e35b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8b0aa6aafcbf93f64b3410d28d9a8f22b38ecaac4953cdb0d0e577d090f3f6a5772f7340cec6a3e259f43b4318e4ce35cc4bed35f5ca9776501b95a1efe7a5b
|
7
|
+
data.tar.gz: 1f556e4a745c961400275e1cb5dbafaa5ac22ef9a23caed138bc12c338c473897c46bb9e2af20396928196b63a87d061d7f953ccff161b8f50725d37340bf6e8
|
data/History.txt
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
TODO / Backlog
|
2
2
|
* add unit tests for all types of graphs
|
3
3
|
* refactor various hardcoded constant pixel offsets in Graph class to use named constants or variables
|
4
|
+
* add support for c3js / d3js based graphs, see http://c3js.org/
|
5
|
+
|
6
|
+
=== 2.2.0 / todo
|
7
|
+
|
8
|
+
|
9
|
+
=== 2.1.3 / 2017-12-27
|
10
|
+
* fixes float comparison and color for pie chart [thanks tiwi, pull request #7]
|
4
11
|
|
5
12
|
=== 2.1.2 / 2017-02-26
|
6
13
|
* show_key_actual_values in pie chart lets user chose to show values in key [thanks olegsfinest, pull request #5]
|
data/lib/SVG/Graph/Pie.rb
CHANGED
@@ -3,30 +3,30 @@ require_relative 'Graph'
|
|
3
3
|
module SVG
|
4
4
|
module Graph
|
5
5
|
# === Create presentation quality SVG pie graphs easily
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# == Synopsis
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# require 'SVG/Graph/Pie'
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# fields = %w(Jan Feb Mar)
|
12
12
|
# data_sales_02 = [12, 45, 21]
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# graph = SVG::Graph::Pie.new({
|
15
15
|
# :height => 500,
|
16
16
|
# :width => 300,
|
17
17
|
# :fields => fields,
|
18
18
|
# })
|
19
|
-
#
|
19
|
+
#
|
20
20
|
# graph.add_data({
|
21
21
|
# :data => data_sales_02,
|
22
22
|
# :title => 'Sales 2002',
|
23
23
|
# })
|
24
|
-
#
|
24
|
+
#
|
25
25
|
# print "Content-type: image/svg+xml\r\n\r\n"
|
26
26
|
# print graph.burn();
|
27
|
-
#
|
27
|
+
#
|
28
28
|
# == Description
|
29
|
-
#
|
29
|
+
#
|
30
30
|
# This object aims to allow you to easily create high quality
|
31
31
|
# SVG pie graphs. You can either use the default style sheet
|
32
32
|
# or supply your own. Either way there are many options which can
|
@@ -35,9 +35,9 @@ module SVG
|
|
35
35
|
# title, subtitle etc.
|
36
36
|
#
|
37
37
|
# = Examples
|
38
|
-
#
|
38
|
+
#
|
39
39
|
# http://www.germane-software/repositories/public/SVG/test/single.rb
|
40
|
-
#
|
40
|
+
#
|
41
41
|
# == See also
|
42
42
|
#
|
43
43
|
# * SVG::Graph::Graph
|
@@ -73,8 +73,8 @@ module SVG
|
|
73
73
|
def set_defaults
|
74
74
|
init_with(
|
75
75
|
:show_shadow => true,
|
76
|
-
:shadow_offset => 10,
|
77
|
-
|
76
|
+
:shadow_offset => 10,
|
77
|
+
|
78
78
|
:show_data_labels => false,
|
79
79
|
:show_actual_values => false,
|
80
80
|
:show_percent => true,
|
@@ -82,11 +82,11 @@ module SVG
|
|
82
82
|
:show_key_data_labels => true,
|
83
83
|
:show_key_actual_values => true,
|
84
84
|
:show_key_percent => false,
|
85
|
-
|
85
|
+
|
86
86
|
:expanded => false,
|
87
87
|
:expand_greatest => false,
|
88
88
|
:expand_gap => 10,
|
89
|
-
|
89
|
+
|
90
90
|
:show_x_labels => false,
|
91
91
|
:show_y_labels => false,
|
92
92
|
:datapoint_font_size => 12
|
@@ -110,7 +110,7 @@ module SVG
|
|
110
110
|
# graph.add_data( { :data => [3,5,8,13] } )
|
111
111
|
#
|
112
112
|
# nil values in the array will be replaced by 0
|
113
|
-
#
|
113
|
+
#
|
114
114
|
# graph.add_data( { :data => [3,nil,nil,2] } ) is equivalent to graph.add_data( { :data => [3,0,0,2] } )
|
115
115
|
#
|
116
116
|
def add_data arg
|
@@ -123,28 +123,28 @@ module SVG
|
|
123
123
|
end
|
124
124
|
|
125
125
|
# If true, displays a drop shadow for the chart
|
126
|
-
attr_accessor :show_shadow
|
126
|
+
attr_accessor :show_shadow
|
127
127
|
# Sets the offset of the shadow from the pie chart
|
128
128
|
attr_accessor :shadow_offset
|
129
129
|
# If true, display the data labels on the chart
|
130
|
-
attr_accessor :show_data_labels
|
130
|
+
attr_accessor :show_data_labels
|
131
131
|
# If true, display the actual field values in the data labels
|
132
|
-
attr_accessor :show_actual_values
|
132
|
+
attr_accessor :show_actual_values
|
133
133
|
# If true, display the percentage value of each pie wedge in the data
|
134
134
|
# labels
|
135
135
|
attr_accessor :show_percent
|
136
136
|
# If true, display the labels in the key
|
137
|
-
attr_accessor :show_key_data_labels
|
137
|
+
attr_accessor :show_key_data_labels
|
138
138
|
# If true, display the actual value of the field in the key
|
139
|
-
attr_accessor :show_key_actual_values
|
139
|
+
attr_accessor :show_key_actual_values
|
140
140
|
# If true, display the percentage value of the wedges in the key
|
141
141
|
attr_accessor :show_key_percent
|
142
142
|
# If true, "explode" the pie (put space between the wedges)
|
143
|
-
attr_accessor :expanded
|
143
|
+
attr_accessor :expanded
|
144
144
|
# If true, expand the largest pie wedge
|
145
|
-
attr_accessor :expand_greatest
|
145
|
+
attr_accessor :expand_greatest
|
146
146
|
# The amount of space between expanded wedges
|
147
|
-
attr_accessor :expand_gap
|
147
|
+
attr_accessor :expand_gap
|
148
148
|
# The font size of the data point labels
|
149
149
|
attr_accessor :datapoint_font_size
|
150
150
|
|
@@ -219,21 +219,20 @@ module SVG
|
|
219
219
|
max_value = max_value < x ? x : max_value
|
220
220
|
total += x
|
221
221
|
}
|
222
|
-
percent_scale = 100.0 / total
|
223
222
|
|
224
223
|
prev_percent = 0
|
225
224
|
rad_mult = 3.6 * RADIANS
|
226
225
|
@config[:fields].each_index { |count|
|
227
226
|
value = @data[count].to_f
|
228
|
-
percent =
|
227
|
+
percent = 100.0 * value / total
|
229
228
|
radians = prev_percent * rad_mult
|
230
229
|
|
231
|
-
if percent == 100.0
|
230
|
+
if percent.rationalize(0.001) == 100.0
|
232
231
|
@foreground.add_element( "circle", {
|
233
232
|
"cx" => radius.to_s,
|
234
233
|
"cy" => radius.to_s,
|
235
234
|
"r" => radius.to_s,
|
236
|
-
"class" => "
|
235
|
+
"class" => "fill#{count+1}"
|
237
236
|
})
|
238
237
|
|
239
238
|
if show_shadow
|
@@ -357,73 +356,73 @@ module SVG
|
|
357
356
|
fill: #ff0000;
|
358
357
|
fill-opacity: 0.7;
|
359
358
|
stroke: none;
|
360
|
-
stroke-width: 1px;
|
359
|
+
stroke-width: 1px;
|
361
360
|
}
|
362
361
|
.key2,.fill2{
|
363
362
|
fill: #0000ff;
|
364
363
|
fill-opacity: 0.7;
|
365
364
|
stroke: none;
|
366
|
-
stroke-width: 1px;
|
365
|
+
stroke-width: 1px;
|
367
366
|
}
|
368
367
|
.key3,.fill3{
|
369
368
|
fill-opacity: 0.7;
|
370
369
|
fill: #00ff00;
|
371
370
|
stroke: none;
|
372
|
-
stroke-width: 1px;
|
371
|
+
stroke-width: 1px;
|
373
372
|
}
|
374
373
|
.key4,.fill4{
|
375
374
|
fill-opacity: 0.7;
|
376
375
|
fill: #ffcc00;
|
377
376
|
stroke: none;
|
378
|
-
stroke-width: 1px;
|
377
|
+
stroke-width: 1px;
|
379
378
|
}
|
380
379
|
.key5,.fill5{
|
381
380
|
fill-opacity: 0.7;
|
382
381
|
fill: #00ccff;
|
383
382
|
stroke: none;
|
384
|
-
stroke-width: 1px;
|
383
|
+
stroke-width: 1px;
|
385
384
|
}
|
386
385
|
.key6,.fill6{
|
387
386
|
fill-opacity: 0.7;
|
388
387
|
fill: #ff00ff;
|
389
388
|
stroke: none;
|
390
|
-
stroke-width: 1px;
|
389
|
+
stroke-width: 1px;
|
391
390
|
}
|
392
391
|
.key7,.fill7{
|
393
392
|
fill-opacity: 0.7;
|
394
393
|
fill: #00ff99;
|
395
394
|
stroke: none;
|
396
|
-
stroke-width: 1px;
|
395
|
+
stroke-width: 1px;
|
397
396
|
}
|
398
397
|
.key8,.fill8{
|
399
398
|
fill-opacity: 0.7;
|
400
399
|
fill: #ffff00;
|
401
400
|
stroke: none;
|
402
|
-
stroke-width: 1px;
|
401
|
+
stroke-width: 1px;
|
403
402
|
}
|
404
403
|
.key9,.fill9{
|
405
404
|
fill-opacity: 0.7;
|
406
405
|
fill: #cc6666;
|
407
406
|
stroke: none;
|
408
|
-
stroke-width: 1px;
|
407
|
+
stroke-width: 1px;
|
409
408
|
}
|
410
409
|
.key10,.fill10{
|
411
410
|
fill-opacity: 0.7;
|
412
411
|
fill: #663399;
|
413
412
|
stroke: none;
|
414
|
-
stroke-width: 1px;
|
413
|
+
stroke-width: 1px;
|
415
414
|
}
|
416
415
|
.key11,.fill11{
|
417
416
|
fill-opacity: 0.7;
|
418
417
|
fill: #339900;
|
419
418
|
stroke: none;
|
420
|
-
stroke-width: 1px;
|
419
|
+
stroke-width: 1px;
|
421
420
|
}
|
422
421
|
.key12,.fill12{
|
423
422
|
fill-opacity: 0.7;
|
424
423
|
fill: #9966FF;
|
425
424
|
stroke: none;
|
426
|
-
stroke-width: 1px;
|
425
|
+
stroke-width: 1px;
|
427
426
|
}
|
428
427
|
EOL
|
429
428
|
end
|
data/lib/svggraph.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: svg-graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Russell
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2017-12-
|
15
|
+
date: 2017-12-27 00:00:00.000000000 Z
|
16
16
|
dependencies: []
|
17
17
|
description: "Gem version of SVG:::Graph. SVG:::Graph is a pure Ruby library for generating
|
18
18
|
charts, \nwhich are a type of graph where the values of one axis are not scalar.
|
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
version: '0'
|
73
73
|
requirements: []
|
74
74
|
rubyforge_project:
|
75
|
-
rubygems_version: 2.6.
|
75
|
+
rubygems_version: 2.6.14
|
76
76
|
signing_key:
|
77
77
|
specification_version: 4
|
78
78
|
summary: SVG:::Graph is a pure Ruby library for generating charts, which are a type
|