flammarion 0.1.8pre → 0.1.8pre1
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.
data/lib/flammarion.rb
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
module Flammarion
|
2
|
+
# A representation of a plot in a writeable area. See {Writeable#plot}
|
3
|
+
class Plot
|
4
|
+
attr_reader :engraving
|
5
|
+
def initialize(*args)
|
6
|
+
if args.size == 0 then
|
7
|
+
@engraving = Engraving.new
|
8
|
+
@id = @engraving.make_id
|
9
|
+
@target = "default"
|
10
|
+
elsif args.size == 3 then
|
11
|
+
id, target, engraving = args
|
12
|
+
@id = id
|
13
|
+
@target = target
|
14
|
+
@engraving = engraving
|
15
|
+
else
|
16
|
+
raise ArgumentError.new("ArgumentError: wrong number of arguments (#{args.size} for 0 or 3)")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def plot(data, options = {})
|
21
|
+
if data.respond_to?(:keys)
|
22
|
+
options = options.merge(data)
|
23
|
+
if data.include?(:xy) then
|
24
|
+
data = data.clone
|
25
|
+
data[:x] = data[:xy].map(&:first)
|
26
|
+
data[:y] = data[:xy].map(&:last)
|
27
|
+
data.delete(:xy)
|
28
|
+
end
|
29
|
+
data = [data]
|
30
|
+
elsif not data.first.respond_to?(:keys)
|
31
|
+
data = [{y:data, x:(1..data.size).to_a}.merge(options)]
|
32
|
+
end
|
33
|
+
@engraving.send_json({action:'plot', id:@id, target:@target, data:data}.merge(options))
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_svg
|
37
|
+
svg = nil
|
38
|
+
@engraving.script(%|$('#plot-i9').find('svg')[0].outerHTML|, coffee:false) {|r| svg = r['result'] || "Error"}
|
39
|
+
sleep(0.1) while svg.nil?
|
40
|
+
return svg
|
41
|
+
end
|
42
|
+
|
43
|
+
def layout(options)
|
44
|
+
@engraving.send_json({action:'plot', id:@id, target: @target, layout: options})
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/flammarion/version.rb
CHANGED
data/lib/flammarion/writeable.rb
CHANGED
@@ -40,39 +40,6 @@ module Flammarion
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
# A representation of a plot in a writeable area. See {Writeable#plot}
|
44
|
-
class Plot
|
45
|
-
attr_reader :engraving
|
46
|
-
def initialize(id, target, engraving)
|
47
|
-
@id = id
|
48
|
-
@target = target
|
49
|
-
@engraving = engraving
|
50
|
-
end
|
51
|
-
|
52
|
-
def plot(data, options = {})
|
53
|
-
if data.respond_to?(:keys)
|
54
|
-
options = options.merge(data)
|
55
|
-
if data.include?(:xy) then
|
56
|
-
data = data.clone
|
57
|
-
data[:x] = data[:xy].map(&:first)
|
58
|
-
data[:y] = data[:xy].map(&:last)
|
59
|
-
data.delete(:xy)
|
60
|
-
end
|
61
|
-
data = [data]
|
62
|
-
elsif not data.first.respond_to?(:keys)
|
63
|
-
data = [{y:data, x:(1..data.size).to_a}.merge(options)]
|
64
|
-
end
|
65
|
-
@engraving.send_json({action:'plot', id:@id, target:@target, data:data}.merge(options))
|
66
|
-
end
|
67
|
-
|
68
|
-
def to_svg
|
69
|
-
svg = nil
|
70
|
-
@engraving.script(%|$('#plot-i9').find('svg')[0].outerHTML|, coffee:false) {|r| svg = r['result'] || "Error"}
|
71
|
-
sleep(0.1) while svg.nil?
|
72
|
-
return svg
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
43
|
# @!macro [new] escape_options
|
77
44
|
# @option options [Boolean] :raw (false) Perform no escaping at all.
|
78
45
|
# @option options [Boolean] :colorize (true) Translate ANSI color escape
|
@@ -7427,7 +7427,10 @@ window.font_awesome_list = ["glass","music","search","envelope-o","heart","star"
|
|
7427
7427
|
}, window.default_plot_options, data));
|
7428
7428
|
} else {
|
7429
7429
|
plotDiv[0].data = data.data;
|
7430
|
-
|
7430
|
+
Plotly.redraw(plotDiv[0]);
|
7431
|
+
if (data.layout) {
|
7432
|
+
return Plotly.relayout(plotDiv[0], data);
|
7433
|
+
}
|
7431
7434
|
}
|
7432
7435
|
}
|
7433
7436
|
});
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flammarion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8pre1
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubame
|
@@ -3819,6 +3819,7 @@ files:
|
|
3819
3819
|
- lib/flammarion/server.rb
|
3820
3820
|
- lib/flammarion/engraving.rb
|
3821
3821
|
- lib/flammarion/pane.rb
|
3822
|
+
- lib/flammarion/plot.rb
|
3822
3823
|
- lib/flammarion/version.rb
|
3823
3824
|
- lib/flammarion/revelator.rb
|
3824
3825
|
- lib/flammarion/writeable.rb
|