SimpleOutput 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +191 -0
- data/include/chartkick.js +759 -0
- data/lib/simplechartkick.rb +138 -0
- data/lib/simpleoutput.rb +319 -0
- data/lib/simpleplot.rb +115 -0
- metadata +49 -0
data/lib/simpleplot.rb
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
=begin
|
2
|
+
SimplePlot
|
3
|
+
|
4
|
+
GnuPlot interface to simpleoutput
|
5
|
+
|
6
|
+
Copyright 2014 Austen Higgins-Cassidy
|
7
|
+
|
8
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
9
|
+
you may not use this file except in compliance with the License.
|
10
|
+
You may obtain a copy of the License at
|
11
|
+
|
12
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
13
|
+
|
14
|
+
Unless required by applicable law or agreed to in writing, software
|
15
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
16
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
17
|
+
See the License for the specific language governing permissions and
|
18
|
+
limitations under the License.
|
19
|
+
=end
|
20
|
+
class SimplePlot < SimpleOutput::SimpleOutputPlugin
|
21
|
+
require 'gnuplot'
|
22
|
+
|
23
|
+
def initialize(name_template="_plot", size = 512)
|
24
|
+
super()
|
25
|
+
@name = name_template
|
26
|
+
@size = size
|
27
|
+
@series_next = 0;
|
28
|
+
@metadata = {}
|
29
|
+
end
|
30
|
+
|
31
|
+
def options_callback(options)
|
32
|
+
if options.has_key?('xlabel')
|
33
|
+
@metadata[@current_name]['xlabel'] = options['xlabel']
|
34
|
+
end
|
35
|
+
if options.has_key?('ylabel')
|
36
|
+
@metadata[@current_name]['ylabel'] = options['ylabel']
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def check_title(name, options)
|
41
|
+
if options.has_key?('series')
|
42
|
+
@metadata[name]['series_titles'] << options['series']
|
43
|
+
else
|
44
|
+
@metadata[name]['series_titles'] << "set-#{@series_next}"
|
45
|
+
@series_next += 1
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def new_series_callback(name)
|
50
|
+
@metadata[name] = {'xlabel' => 'x', 'ylabel' => 'y', 'xmin' => 0 , 'xmax' => 10, 'ymin' => 0, 'ymax' => 10, 'series_titles' => []}
|
51
|
+
end
|
52
|
+
|
53
|
+
def set_x_callback(data, name, options)
|
54
|
+
xmin = data.min
|
55
|
+
xmax = data.max
|
56
|
+
@metadata[name]['xmin'] = xmin
|
57
|
+
@metadata[name]['xmax'] = xmax
|
58
|
+
check_title(name, options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def set_y_callback(data, name, options)
|
62
|
+
ymin = data.min
|
63
|
+
ymax = data.max
|
64
|
+
@metadata[name]['ymin'] = ymin
|
65
|
+
@metadata[name]['ymax'] = ymax
|
66
|
+
end
|
67
|
+
|
68
|
+
def append_callback(x,y,name,options)
|
69
|
+
xmin = x.min
|
70
|
+
xmax = x.max
|
71
|
+
ymin = y.min
|
72
|
+
ymax = y.max
|
73
|
+
if !@metadata.has_key?(name)
|
74
|
+
new_series_callback(name)
|
75
|
+
end
|
76
|
+
@metadata[name]['xmin'] = xmin < @metadata[name]['xmin'] ? xmin : @metadata[name]['xmin']
|
77
|
+
@metadata[name]['xmax'] = xmax > @metadata[name]['xmax'] ? xmax : @metadata[name]['xmax']
|
78
|
+
@metadata[name]['ymin'] = ymin < @metadata[name]['ymin'] ? ymin : @metadata[name]['ymin']
|
79
|
+
@metadata[name]['ymax'] = ymax > @metadata[name]['ymax'] ? ymax : @metadata[name]['ymax']
|
80
|
+
check_title(name, options)
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
def save()
|
85
|
+
data = self.getDataAsXY()
|
86
|
+
Gnuplot.open do |gp|
|
87
|
+
data.each do |set_name, series|
|
88
|
+
Gnuplot::Plot.new(gp) do |plot|
|
89
|
+
plot.terminal "png"
|
90
|
+
#plot.size 0.95
|
91
|
+
plot.output "#{set_name+@name}.png"
|
92
|
+
|
93
|
+
plot.title set_name
|
94
|
+
|
95
|
+
plot.xlabel @metadata[set_name]['xlabel']
|
96
|
+
plot.ylabel @metadata[set_name]['ylabel']
|
97
|
+
plot.xrange "[#{@metadata[set_name]['xmin']}:#{@metadata[set_name]['xmax']}]"
|
98
|
+
plot.yrange "[#{@metadata[set_name]['ymin']}:#{@metadata[set_name]['ymax']}]"
|
99
|
+
plot.data = []
|
100
|
+
series.each_with_index do |line, index|
|
101
|
+
d = Gnuplot::DataSet.new(line)
|
102
|
+
d.title = @metadata[set_name]['series_titles'][index]
|
103
|
+
d.with = "linespoints"
|
104
|
+
d.linewidth = 2
|
105
|
+
plot.data << d
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: SimpleOutput
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Austen Higgins-Cassidy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-24 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A pluging based graphing and report rendering system with multiple simultanous
|
14
|
+
output systems supported
|
15
|
+
email: plasmarobo@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- LICENSE
|
21
|
+
- include/chartkick.js
|
22
|
+
- lib/simplechartkick.rb
|
23
|
+
- lib/simpleoutput.rb
|
24
|
+
- lib/simpleplot.rb
|
25
|
+
homepage: https://github.com/Plasmarobo/simpleoutput
|
26
|
+
licenses:
|
27
|
+
- Apache 2.0
|
28
|
+
metadata: {}
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 2.2.2
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: A Simple Engine to output data
|
49
|
+
test_files: []
|