nyaplot 0.1.6 → 0.2.0.rc1
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/.gitignore +1 -0
- data/.gitmodules +4 -3
- data/examples/notebook/3DPlot.ipynb +398 -455
- data/examples/notebook/Interaction_with_DataFrame.ipynb +572 -650
- data/examples/notebook/Introduction.ipynb +452 -525
- data/examples/notebook/Mapnya.ipynb +441 -212
- data/examples/notebook/Nyaplotv2.ipynb +307 -0
- data/lib/nyaplot.rb +7 -3
- data/lib/nyaplot/base.rb +80 -46
- data/lib/nyaplot/core.rb +45 -5
- data/lib/nyaplot/data.rb +220 -172
- data/lib/nyaplot/glyph.rb +227 -0
- data/lib/nyaplot/interactive.rb +94 -0
- data/lib/nyaplot/pane.rb +43 -0
- data/lib/nyaplot/plot.rb +173 -124
- data/lib/nyaplot/position.rb +7 -0
- data/lib/nyaplot/scale.rb +19 -0
- data/lib/nyaplot/sheet.rb +83 -0
- data/lib/nyaplot/simple/stage.rb +29 -0
- data/lib/nyaplot/stage2d.rb +56 -0
- data/lib/nyaplot/templates/init.js.erb +1 -1
- data/lib/nyaplot/templates/init_interactive.js +77 -0
- data/lib/nyaplot/templates/iruby.erb +2 -9
- data/lib/nyaplot/version.rb +1 -1
- data/lib/nyaplot3d/core.rb +1 -1
- data/nyaplot.gemspec +1 -26
- metadata +29 -10
- data/lib/mapnya/datasets/geo-boundaries-world-110m/README.md +0 -3
- data/lib/mapnya/datasets/geo-boundaries-world-110m/countries.geojson +0 -360
- data/lib/mapnya/datasets/geo-boundaries-world-110m/datapackage.json +0 -35
- data/lib/nyaplot/database.rb +0 -22
- data/lib/nyaplot/diagram.rb +0 -341
- data/lib/nyaplot/frame.rb +0 -70
data/lib/nyaplot/frame.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'securerandom'
|
3
|
-
|
4
|
-
module Nyaplot
|
5
|
-
|
6
|
-
# Jsonizable Object which holds Plots (panes) in it.
|
7
|
-
class Frame
|
8
|
-
include Jsonizable
|
9
|
-
|
10
|
-
define_properties(:data, :panes, :extension)
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
init_properties
|
14
|
-
set_property(:panes, [])
|
15
|
-
set_property(:data, {})
|
16
|
-
end
|
17
|
-
|
18
|
-
# Add new pane to the frame
|
19
|
-
# @param [Nyaplot::Plot] the pane to add
|
20
|
-
def add(plot)
|
21
|
-
data = get_property(:data)
|
22
|
-
plot.df_list.each do |name|
|
23
|
-
data[name] = DataBase.instance.fetch(name)
|
24
|
-
end
|
25
|
-
panes = get_property(:panes)
|
26
|
-
panes.push(plot)
|
27
|
-
end
|
28
|
-
|
29
|
-
# generate html code for <body> tag
|
30
|
-
def generate_body
|
31
|
-
path = File.expand_path("../templates/iruby.erb", __FILE__)
|
32
|
-
template = File.read(path)
|
33
|
-
id = SecureRandom.uuid()
|
34
|
-
model = self.to_json
|
35
|
-
ERB.new(template).result(binding)
|
36
|
-
end
|
37
|
-
|
38
|
-
# generate static html file
|
39
|
-
# @return [String] generated html
|
40
|
-
def generate_html
|
41
|
-
body = generate_body
|
42
|
-
init = Nyaplot.generate_init_code
|
43
|
-
path = File.expand_path("../templates/static_html.erb", __FILE__)
|
44
|
-
template = File.read(path)
|
45
|
-
ERB.new(template).result(binding)
|
46
|
-
end
|
47
|
-
|
48
|
-
# export static html file
|
49
|
-
def export_html(path="./plot.html")
|
50
|
-
path = File.expand_path(path, Dir::pwd)
|
51
|
-
str = generate_html
|
52
|
-
File.write(path, str)
|
53
|
-
end
|
54
|
-
|
55
|
-
# show plot automatically on IRuby notebook
|
56
|
-
def to_iruby
|
57
|
-
html = generate_body
|
58
|
-
['text/html', html]
|
59
|
-
end
|
60
|
-
|
61
|
-
# show plot on IRuby notebook
|
62
|
-
def show
|
63
|
-
IRuby.display(self)
|
64
|
-
end
|
65
|
-
|
66
|
-
def before_to_json
|
67
|
-
set_property(:extension, Nyaplot.extension_lists)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|