From 53c0bcd09f485ec1acc9a24c3da9608881da11fc Mon Sep 17 00:00:00 2001 From: Naoki Nishida Date: Fri, 24 Apr 2015 01:15:13 +0900 Subject: [PATCH 1/3] Add Plot#scale_x and #scale_y --- lib/nyaplot/plot.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/nyaplot/plot.rb b/lib/nyaplot/plot.rb index de8df87..5c60843 100644 --- a/lib/nyaplot/plot.rb +++ b/lib/nyaplot/plot.rb @@ -34,8 +34,12 @@ class Plot # @return [Numeric] the angle to rotate x label (radian) # @!attribute rotate_y_label # @return [Numeric] the angle to rotate y label (radian) + # @!attribute x_scale + # @return [String] the type of scale ("linear", "log" and "pow" are supported.) + # @!attribute y_scale + # @return [String] the type of scale ("linear", "log" and "pow" are supported.) define_properties(:diagrams, :filter) - define_group_properties(:options, [:width, :height, :margin, :xrange, :yrange, :x_label, :y_label, :bg_color, :grid_color, :legend, :legend_width, :legend_options, :zoom, :rotate_x_label, :rotate_y_label]) + define_group_properties(:options, [:width, :height, :margin, :xrange, :yrange, :x_label, :y_label, :bg_color, :grid_color, :legend, :legend_width, :legend_options, :zoom, :rotate_x_label, :rotate_y_label, :x_scale, :y_scale]) def initialize(&block) init_properties From 56f26e1b505bdfa024cf889ed74546e98291bbc9 Mon Sep 17 00:00:00 2001 From: Naoki Nishida Date: Fri, 24 Apr 2015 01:20:27 +0900 Subject: [PATCH 2/3] v0.1.4 --- lib/nyaplot/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/nyaplot/version.rb b/lib/nyaplot/version.rb index 81eb76e..7a162a2 100644 --- a/lib/nyaplot/version.rb +++ b/lib/nyaplot/version.rb @@ -1,3 +1,3 @@ module Nyaplot - VERSION = "0.1.3" + VERSION = "0.1.4" end From cb7fe27cfbca8faab4ac3681cf5d2cb682fd3070 Mon Sep 17 00:00:00 2001 From: Naoki Nishida Date: Sun, 17 May 2015 13:16:11 +0900 Subject: [PATCH 3/3] Enable to download charts as SVG, PNG and JPG --- lib/nyaplot/core.rb | 5 ++++- lib/nyaplot/templates/iruby.erb | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/nyaplot/core.rb b/lib/nyaplot/core.rb index 20672b2..a6a1a62 100644 --- a/lib/nyaplot/core.rb +++ b/lib/nyaplot/core.rb @@ -2,7 +2,10 @@ module Nyaplot - @@dep_libraries = {d3:'http://d3js.org/d3.v3.min'} + @@dep_libraries = { + d3:'http://d3js.org/d3.v3.min', + downloadable: 'http://cdn.rawgit.com/domitry/d3-downloadable/master/d3-downloadable' + } @@additional_libraries = {} @@extension_lists = [] diff --git a/lib/nyaplot/templates/iruby.erb b/lib/nyaplot/templates/iruby.erb index 582bec7..098ec2c 100644 --- a/lib/nyaplot/templates/iruby.erb +++ b/lib/nyaplot/templates/iruby.erb @@ -3,7 +3,14 @@ (function(){ var render = function(){ var model = <%= model %> - Nyaplot.core.parse(model, '#vis-<%= id %>'); + var id_name = '#vis-<%= id %>'; + Nyaplot.core.parse(model, id_name); + + require(['downloadable'], function(downloadable){ + var svg = d3.select(id_name).select("svg"); + if(!svg.empty()) + svg.call(downloadable().filename('fig')); + }); }; if(window['Nyaplot']==undefined){ window.addEventListener('load_nyaplot', render, false);