svg-graph 2.2.0.beta → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ffe9d9ef41e6f8e53cc9acc30eea176b5c08df460fecd4809e5a974930b07316
4
- data.tar.gz: c7a4de59354a36eb79da7c3b337859425b348a17ba11254a155a8cc4f761d41f
3
+ metadata.gz: c448a6423accd8618fa44587eeca0dc4f7b21ea99508c21dd95e5329cef59a5c
4
+ data.tar.gz: 4775e687abb3ebe350754e3287b925ab6b5d5624158664aacecfffc6cbcff680
5
5
  SHA512:
6
- metadata.gz: 742d05482c8cdecf6359ca8aac09e0c1e307c9e063934b3b029908b4ceac87477ea5f3089b44ddebec41c58c5d56b22734246d741a78fb697eee8bc54ffba46d
7
- data.tar.gz: '078f9a897f0fca0e88b3483e84aba191fb8bfa3eb46bd6505565f0de037d08a12ecb86770270e53ba7e607c0018291b22f4b668af9ec0549d562775e430d6b96'
6
+ metadata.gz: 3ba65a950336a3718b7c0fd01ddcd55261911ac00542518914165e22388bdbafd834ed928980af8aa4ad75523ad8572110fb82ef5b933897243b2153d52aed38
7
+ data.tar.gz: 19166679a0a198b667c240162aeb2438f77662130a03cbf430b289804b286b0fcd0c7e743b245eaebe2e982110946482ec6da94a02e29cc15d633808b74d952d
@@ -2,6 +2,10 @@ TODO / Backlog
2
2
  * refactor various hardcoded constant pixel offsets in Graph class to use named constants or variables
3
3
  * Fix bug in Plot where min/max_x/y_value are not respected, TODO
4
4
 
5
+ === 2.2.0 / 2019-11-26
6
+ * on top of 2.2.0.beta adds the following
7
+ * Fixed Divizion by zero when data is 0,0 in Pie [thanks chrismedrdz, PR #16]
8
+ * Automatically render graphs in iruby [thanks dansbits, PR #14]
5
9
 
6
10
  === 2.2.0.beta / 2019-05-07
7
11
  * Fix typo in Plot's `scale_y_integers` [thanks ashleydavies, PR #9]
data/Rakefile CHANGED
@@ -28,4 +28,5 @@ task :test do
28
28
  ruby "test/test_data_point.rb"
29
29
  ruby "test/test_plot.rb"
30
30
  ruby "test/test_svg_graph.rb"
31
+ ruby "test/test_graph.rb"
31
32
  end
@@ -48,9 +48,9 @@ module SVG
48
48
  def initialize(opts = {})
49
49
  default_opts = {
50
50
  "inline_dependencies" => false,
51
- "d3_js" => "https://cdnjs.cloudflare.com/ajax/libs/d3/5.9.2/d3.min.js",
52
- "c3_css" => "https://cdnjs.cloudflare.com/ajax/libs/c3/0.7.0/c3.min.css",
53
- "c3_js" => "https://cdnjs.cloudflare.com/ajax/libs/c3/0.7.0/c3.min.js"
51
+ "d3_js" => "https://cdnjs.cloudflare.com/ajax/libs/d3/5.12.0/d3.min.js",
52
+ "c3_css" => "https://cdnjs.cloudflare.com/ajax/libs/c3/0.7.11/c3.min.css",
53
+ "c3_js" => "https://cdnjs.cloudflare.com/ajax/libs/c3/0.7.11/c3.min.js"
54
54
  }
55
55
  @opts = default_opts.merge(opts)
56
56
  if @opts["inline_dependencies"]
@@ -254,6 +254,14 @@ module SVG
254
254
  return out
255
255
  end
256
256
 
257
+ # Burns the graph to an SVG string and returns it with a text/html mime type to be
258
+ # displayed in IRuby.
259
+ #
260
+ # @return [Array] A 2-dimension array containing the SVg string and a mime-type. This is the format expected by IRuby.
261
+ def to_iruby
262
+ ["text/html", burn_svg_only]
263
+ end
264
+
257
265
 
258
266
  # Set the height of the graph box, this is the total height
259
267
  # of the SVG box created - not the graph it self which auto
@@ -224,7 +224,7 @@ module SVG
224
224
  rad_mult = 3.6 * RADIANS
225
225
  @config[:fields].each_index { |count|
226
226
  value = @data[count].to_f
227
- percent = 100.0 * value / total
227
+ percent = total.zero? ? 0.0 : 100.0 * value / total
228
228
  radians = prev_percent * rad_mult
229
229
 
230
230
  if percent.rationalize(0.001) == 100.0
@@ -1,6 +1,6 @@
1
1
  module SVG
2
2
  module Graph
3
- VERSION = '2.2.0.beta'
3
+ VERSION = '2.2.0'
4
4
 
5
5
  end
6
6
  end
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.2.0.beta
4
+ version: 2.2.0
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: 2019-05-07 00:00:00.000000000 Z
15
+ date: 2019-11-26 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.
@@ -68,9 +68,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
68
  version: '0'
69
69
  required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - ">"
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
- version: 1.3.1
73
+ version: '0'
74
74
  requirements: []
75
75
  rubygems_version: 3.0.1
76
76
  signing_key: