charty-backends-jfreechart 0.2.0-java → 0.3.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -3
- data/charty-backends-jfreechart.gemspec +1 -2
- data/lib/charty/backends/jfreechart.rb +137 -144
- data/lib/charty/backends/jfreechart/version.rb +2 -2
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d41b2c32f084ae212171fca17d7a82a955aca4c0c8d9c6caf27757351621468d
|
4
|
+
data.tar.gz: 866681ca87ffae6c85d16996514e4f1d9ac08e827798f4fe64c56ec16ed69479
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a5237beacfc478199c7d243862cfab3971c2d534ff572b6038ef14e9425753829f75ec5bc4c8ac8763037ef360721202e47c6ab5a94e6e2f4411e8de334fe97
|
7
|
+
data.tar.gz: 895dfdda93147d4e61f4f6d2b198720881007a0c0a8ba923c14cc315b1eb756ccf7264a308889cb5a83c585d9156727dd41005525f0dc2f5148f9b877a8ef683
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# Charty::Backends::Jfreechart
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Charty JFreeChart backend adapter
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -4,7 +4,7 @@ require "charty/backends/jfreechart/version"
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "charty-backends-jfreechart"
|
7
|
-
spec.version = Charty::Backends::
|
7
|
+
spec.version = Charty::Backends::JFreeChart::VERSION
|
8
8
|
spec.authors = ["284km"]
|
9
9
|
spec.email = ["k.furuhashi10@gmail.com"]
|
10
10
|
|
@@ -31,7 +31,6 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
33
|
spec.add_dependency "charty"
|
34
|
-
spec.add_dependency "fileutils"
|
35
34
|
spec.add_development_dependency "bundler"
|
36
35
|
spec.add_development_dependency "rake"
|
37
36
|
spec.add_development_dependency "test-unit"
|
@@ -13,165 +13,158 @@ java_import 'org.jfree.data.xy.XYSeriesCollection'
|
|
13
13
|
|
14
14
|
module Charty
|
15
15
|
module Backends
|
16
|
-
|
17
|
-
|
18
|
-
# Your code goes here...
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
16
|
+
class JFreeChart
|
17
|
+
Backends.register(:jfreechart, self)
|
22
18
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
def initialize
|
28
|
-
@plot = ChartFactory
|
29
|
-
end
|
19
|
+
def initialize
|
20
|
+
@plot = ::ChartFactory
|
21
|
+
end
|
30
22
|
|
31
|
-
|
32
|
-
|
23
|
+
def label(x, y)
|
24
|
+
end
|
33
25
|
|
34
|
-
|
35
|
-
|
36
|
-
|
26
|
+
def series=(series)
|
27
|
+
@series = series
|
28
|
+
end
|
37
29
|
|
38
|
-
|
39
|
-
|
40
|
-
|
30
|
+
def render_layout(layout)
|
31
|
+
raise NotImplementedError
|
32
|
+
end
|
41
33
|
|
42
|
-
|
43
|
-
|
34
|
+
def render(context, filename)
|
35
|
+
# todo: I'm not sure if I can only render.
|
44
36
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
37
|
+
chart = plot(@plot, context)
|
38
|
+
# todo: add options for width and height
|
39
|
+
width = 1000
|
40
|
+
height = 800
|
41
|
+
if filename
|
42
|
+
FileUtils.mkdir_p(File.dirname(filename))
|
43
|
+
javafile = java.io.File.new(filename)
|
44
|
+
ChartUtilities.saveChartAsPNG(javafile, chart, width, height)
|
45
|
+
end
|
53
46
|
end
|
54
|
-
end
|
55
47
|
|
56
|
-
|
57
|
-
|
58
|
-
|
48
|
+
def save(context, filename)
|
49
|
+
# todo:
|
50
|
+
end
|
59
51
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
52
|
+
def plot(plot, context, subplot: false)
|
53
|
+
case context.method
|
54
|
+
when :bar
|
55
|
+
dataset = DefaultCategoryDataset.new
|
56
|
+
context.series.each do |data|
|
57
|
+
data.ys.to_a.zip(Array.new(data.xs.size, data.label.to_s), data.xs.to_a.map(&:to_s)).each do |d|
|
58
|
+
dataset.addValue(*d)
|
59
|
+
end
|
67
60
|
end
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
61
|
+
title = context.title || ""
|
62
|
+
xlabel = context.xlabel || ""
|
63
|
+
ylabel = context.ylabel || ""
|
64
|
+
plot.createBarChart(
|
65
|
+
title,
|
66
|
+
xlabel,
|
67
|
+
ylabel,
|
68
|
+
dataset,
|
69
|
+
PlotOrientation::VERTICAL,
|
70
|
+
true,
|
71
|
+
false,
|
72
|
+
false
|
73
|
+
)
|
74
|
+
when :barh
|
75
|
+
dataset = DefaultCategoryDataset.new
|
76
|
+
context.series.each do |data|
|
77
|
+
data.ys.to_a.zip(Array.new(data.xs.size, data.label.to_s), data.xs.to_a.map(&:to_s)).each do |d|
|
78
|
+
dataset.addValue(*d)
|
79
|
+
end
|
87
80
|
end
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
81
|
+
title = context.title || ""
|
82
|
+
xlabel = context.xlabel || ""
|
83
|
+
ylabel = context.ylabel || ""
|
84
|
+
plot.createBarChart(
|
85
|
+
title,
|
86
|
+
xlabel,
|
87
|
+
ylabel,
|
88
|
+
dataset,
|
89
|
+
PlotOrientation::HORIZONTAL,
|
90
|
+
true,
|
91
|
+
false,
|
92
|
+
false
|
93
|
+
)
|
94
|
+
when :box_plot
|
95
|
+
# todo:
|
96
|
+
raise NotImplementedError
|
97
|
+
when :bubble
|
98
|
+
dataset = MatrixSeriesCollection.new
|
99
|
+
context.series.each do |data|
|
100
|
+
# todo: fix args
|
101
|
+
series = MatrixSeries.new(data.label.to_s, 1000, 1000)
|
102
|
+
data.xs.to_a.zip(data.ys.to_a, data.zs.to_a).each do |series_param|
|
103
|
+
series.update(*series_param)
|
104
|
+
end
|
105
|
+
dataset.addSeries(series)
|
112
106
|
end
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
dataset.addValue(a[1], data.label.to_s, a[0])
|
107
|
+
title = context.title || ""
|
108
|
+
xlabel = context.xlabel || ""
|
109
|
+
ylabel = context.ylabel || ""
|
110
|
+
plot.createBubbleChart(
|
111
|
+
title,
|
112
|
+
xlabel,
|
113
|
+
ylabel,
|
114
|
+
dataset,
|
115
|
+
PlotOrientation::VERTICAL,
|
116
|
+
true,
|
117
|
+
false,
|
118
|
+
false
|
119
|
+
)
|
120
|
+
when :curve
|
121
|
+
dataset = DefaultCategoryDataset.new
|
122
|
+
context.series.each do |data|
|
123
|
+
data.xs.to_a.zip(data.ys.to_a).each do |a|
|
124
|
+
dataset.addValue(a[1], data.label.to_s, a[0])
|
125
|
+
end
|
133
126
|
end
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
127
|
+
title = context.title || ""
|
128
|
+
xlabel = context.xlabel || ""
|
129
|
+
ylabel = context.ylabel || ""
|
130
|
+
plot.createLineChart(
|
131
|
+
title,
|
132
|
+
xlabel,
|
133
|
+
ylabel,
|
134
|
+
dataset,
|
135
|
+
PlotOrientation::VERTICAL,
|
136
|
+
true,
|
137
|
+
false,
|
138
|
+
false
|
139
|
+
)
|
140
|
+
when :scatter
|
141
|
+
dataset = XYSeriesCollection.new
|
142
|
+
context.series.each do |data|
|
143
|
+
series = XYSeries.new(data.label.to_s)
|
144
|
+
data.xs.to_a.zip(data.ys.to_a).each do |series_param|
|
145
|
+
series.add(*series_param)
|
146
|
+
end
|
147
|
+
dataset.addSeries(series)
|
154
148
|
end
|
155
|
-
|
149
|
+
title = context.title || ""
|
150
|
+
xlabel = context.xlabel || ""
|
151
|
+
ylabel = context.ylabel || ""
|
152
|
+
plot.createScatterPlot(
|
153
|
+
title,
|
154
|
+
xlabel,
|
155
|
+
ylabel,
|
156
|
+
dataset,
|
157
|
+
PlotOrientation::VERTICAL,
|
158
|
+
true,
|
159
|
+
false,
|
160
|
+
false
|
161
|
+
)
|
162
|
+
when :error_bar
|
163
|
+
raise NotImplementedError
|
164
|
+
when :hist
|
165
|
+
# todo:
|
166
|
+
raise NotImplementedError
|
156
167
|
end
|
157
|
-
title = context.title || ""
|
158
|
-
xlabel = context.xlabel || ""
|
159
|
-
ylabel = context.ylabel || ""
|
160
|
-
plot.createScatterPlot(
|
161
|
-
title,
|
162
|
-
xlabel,
|
163
|
-
ylabel,
|
164
|
-
dataset,
|
165
|
-
PlotOrientation::VERTICAL,
|
166
|
-
true,
|
167
|
-
false,
|
168
|
-
false
|
169
|
-
)
|
170
|
-
when :error_bar
|
171
|
-
raise NotImplementedError
|
172
|
-
when :hist
|
173
|
-
# todo:
|
174
|
-
raise NotImplementedError
|
175
168
|
end
|
176
169
|
end
|
177
170
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: charty-backends-jfreechart
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- 284km
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
requirement: !ruby/object:Gem::Requirement
|
43
|
-
requirements:
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '0'
|
47
|
-
name: fileutils
|
48
|
-
prerelease: false
|
49
|
-
type: :runtime
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
requirement: !ruby/object:Gem::Requirement
|
57
43
|
requirements:
|