treemap21 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/treemap21.rb +39 -100
- metadata +23 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0c0ef895191c2b9096739debe2f5fc0587e0de4cd1e79353d476fa5d8f9511f
|
4
|
+
data.tar.gz: 4275d68e6f555f9b523238e418551fcdf3ac9e9d6e2c481d38b06399cd625c2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89e4ef858bb13e906b729720e0bea919959b464c8e662b421cad97c9ccdf0d010b1aa31453a8cd1d8e7d91838aa5b85256c8bd19b9364c0dfca29d32d953cbc0
|
7
|
+
data.tar.gz: af28c7e0cae6d56c98b03b3d328a27d0c4c724b739df29dc0a1ce0721849356072731f98efd70ea07c2711ab347f79cf907d567efb11b775ab16e262395f0dc0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/treemap21.rb
CHANGED
@@ -2,17 +2,21 @@
|
|
2
2
|
|
3
3
|
# file: treemap21.rb
|
4
4
|
|
5
|
+
require 'c32'
|
5
6
|
require 'rexle'
|
7
|
+
require 'weblet'
|
6
8
|
require 'polyrex'
|
7
9
|
|
8
10
|
|
9
11
|
class Treemap21
|
12
|
+
using ColouredText
|
10
13
|
|
11
|
-
attr_reader :to_html
|
14
|
+
attr_reader :to_html, :title
|
12
15
|
|
13
|
-
def initialize(obj, orientation: :landscape,
|
16
|
+
def initialize(obj, orientation: :landscape, title: 'Treemap',
|
17
|
+
weblet_file: nil, debug: false)
|
14
18
|
|
15
|
-
@orientation, @debug = orientation, debug
|
19
|
+
@orientation, @title, @debug = orientation, title, debug
|
16
20
|
|
17
21
|
@a = case obj
|
18
22
|
when Array
|
@@ -48,13 +52,15 @@ class Treemap21
|
|
48
52
|
|
49
53
|
end
|
50
54
|
|
51
|
-
|
55
|
+
weblet_file ||= File.join(File.dirname(__FILE__), '..', 'data',
|
56
|
+
'treemap21.txt')
|
57
|
+
@to_html = build_html(weblet_file)
|
52
58
|
|
53
59
|
end
|
54
60
|
|
55
61
|
private
|
56
62
|
|
57
|
-
def build_html()
|
63
|
+
def build_html(weblet_file)
|
58
64
|
|
59
65
|
# used for the box id
|
60
66
|
@counter, @count = 2, 1
|
@@ -68,82 +74,13 @@ class Treemap21
|
|
68
74
|
end
|
69
75
|
|
70
76
|
boxes = doc.root.xml pretty: true
|
71
|
-
|
72
|
-
|
73
|
-
<<EOF
|
74
|
-
<html>
|
75
|
-
<head>
|
76
|
-
<style>
|
77
|
-
.cbox, .long, .cbox1, .cbox1 a {
|
78
|
-
width: 100%;
|
79
|
-
height: 100%;
|
80
|
-
}
|
81
|
-
.long, .cbox1 {
|
82
|
-
float: left;
|
83
|
-
}
|
84
|
-
.cbox1, .cbox1 a {
|
85
|
-
display: flex;
|
86
|
-
justify-content: center;
|
87
|
-
align-items: center;
|
88
|
-
}
|
77
|
+
w = Weblet.new(weblet_file)
|
89
78
|
|
90
|
-
.
|
91
|
-
text-decoration: none;
|
92
|
-
color: #010;
|
93
|
-
font-family: helvetica, arial;
|
94
|
-
color: #115;
|
95
|
-
}
|
96
|
-
|
97
|
-
.cbox1 a:hover { background-color: rgba(255,255,255,0.2); color: #902}
|
98
|
-
.cbox1 span { background-color: transparent; color2: #300 }
|
79
|
+
w.render :html, binding
|
99
80
|
|
100
|
-
.cbox {position: relative}
|
101
|
-
|
102
|
-
.glabel {
|
103
|
-
background-color: #111;
|
104
|
-
width: 100%;
|
105
|
-
height: 30px;
|
106
|
-
color: #fff; font-size: 1.6vw;
|
107
|
-
position: absolute;
|
108
|
-
z-index: 1
|
109
|
-
}
|
110
|
-
|
111
|
-
.gfoot {
|
112
|
-
background-color: #111;
|
113
|
-
width: 100%;
|
114
|
-
height: 20px;
|
115
|
-
position: absolute;
|
116
|
-
bottom: 0;
|
117
|
-
}
|
118
|
-
|
119
|
-
.group { border: 0px solid black;}
|
120
|
-
|
121
|
-
.c10 {font-size: 8vw}
|
122
|
-
.c9 {font-size: 7.5vw}
|
123
|
-
.c8 {font-size: 6vw}
|
124
|
-
.c7 {font-size: 5.0vw}
|
125
|
-
.c6 {font-size: 4.9vw}
|
126
|
-
.c5 {font-size: 4.5vw}
|
127
|
-
.c4 {font-size: 3.6vw}
|
128
|
-
.c3 {font-size: 2.6vw}
|
129
|
-
.c2 {font-size: 2.4vw}
|
130
|
-
.c1 {font-size: 1.6vw}
|
131
|
-
.c0 {font-size: 1.1vw}
|
132
|
-
|
133
|
-
#{cbox_css.join("\n")}
|
134
|
-
|
135
|
-
</style>
|
136
|
-
</head>
|
137
|
-
<body>
|
138
|
-
|
139
|
-
#{boxes}
|
140
|
-
|
141
|
-
</body>
|
142
|
-
</html>
|
143
|
-
EOF
|
144
81
|
end
|
145
82
|
|
146
|
-
def add_box(text, url=nil, attr={}
|
83
|
+
def add_box(text, url=nil, attr={})
|
147
84
|
|
148
85
|
span = Rexle::Element.new('span', value: text)
|
149
86
|
|
@@ -151,14 +88,14 @@ EOF
|
|
151
88
|
|
152
89
|
h = {
|
153
90
|
id: 'cbox' + @count.to_s,
|
154
|
-
class: 'cbox1 '
|
91
|
+
class: 'cbox1 '
|
155
92
|
}
|
156
93
|
@count = @count + 1
|
157
94
|
|
158
95
|
doc = Rexle::Element.new('div', attributes: h)
|
159
96
|
|
160
97
|
if url then
|
161
|
-
anchor = Rexle::Element.new('a', attributes: {href: url})
|
98
|
+
anchor = Rexle::Element.new('a', attributes: {href: url, draggable: 'false'})
|
162
99
|
anchor.root.add span
|
163
100
|
doc.root.add anchor.root
|
164
101
|
else
|
@@ -170,13 +107,12 @@ EOF
|
|
170
107
|
|
171
108
|
end
|
172
109
|
|
173
|
-
def mapper(doc, a, orientation: :landscape, total: 100
|
110
|
+
def mapper(doc, a, orientation: :landscape, total: 100)
|
174
111
|
|
175
112
|
if @debug then
|
176
113
|
puts 'a: ' + a.inspect
|
177
114
|
puts 'orientation: ' + orientation.inspect
|
178
115
|
puts 'total: ' + total.inspect
|
179
|
-
puts 'scale: ' + scale.inspect
|
180
116
|
end
|
181
117
|
|
182
118
|
klass = if orientation == :landscape then
|
@@ -216,7 +152,7 @@ EOF
|
|
216
152
|
rpct = 100 / (total / percent.to_f)
|
217
153
|
rem_pct = 100 - rpct
|
218
154
|
|
219
|
-
new_orientation = if rpct.round <=
|
155
|
+
new_orientation = if rpct.round <= 133 and rpct.round >= 9993 then
|
220
156
|
orientation
|
221
157
|
else
|
222
158
|
orientation == :landscape ? :portrait : :landscape
|
@@ -225,11 +161,12 @@ EOF
|
|
225
161
|
puts 'new_orientation: ' + new_orientation.inspect if @debug
|
226
162
|
|
227
163
|
dimension = orientation == :landscape ? :width : :height
|
228
|
-
|
164
|
+
hstyle = { dimension => rpct.round.to_s + '%' }
|
165
|
+
style = hstyle.map {|key, value| "%s: %s" % [key, value]}.join(';')
|
229
166
|
|
230
167
|
h = {
|
231
168
|
class: klass,
|
232
|
-
style: style
|
169
|
+
style: style
|
233
170
|
}
|
234
171
|
|
235
172
|
div = Rexle::Element.new('div', attributes: h)
|
@@ -240,7 +177,7 @@ EOF
|
|
240
177
|
# it's a group item
|
241
178
|
group_name, url = item.values_at(0, 2)
|
242
179
|
#<div class='glabel'> <span>Group A</span> </div>
|
243
|
-
group = Rexle::Element.new('div', attributes: {class: 'glabel'})
|
180
|
+
group = Rexle::Element.new('div', attributes: {style: style, class: 'glabel'})
|
244
181
|
span = Rexle::Element.new('span', value: group_name)
|
245
182
|
|
246
183
|
if url then
|
@@ -256,28 +193,28 @@ EOF
|
|
256
193
|
end
|
257
194
|
|
258
195
|
div.add group
|
259
|
-
|
260
|
-
doc4 = Rexle.new("<div id='box%s' class='%s' style='%s: %s%%'/>" % \
|
261
|
-
[@counter, klass, dimension, rem_pct.round.to_s])
|
262
|
-
|
263
|
-
mapper(div, item[3], orientation: orientation, scale: scale)
|
264
196
|
|
265
|
-
|
266
|
-
|
197
|
+
style = "%s: %s%%; font-size: %s%%" % [ dimension, rem_pct.round,
|
198
|
+
rem_pct.round]
|
199
|
+
doc4 = Rexle.new("<div id='box%s' class='%s' style='%s'/>" % \
|
200
|
+
[@counter, klass, style])
|
201
|
+
puts ('rem_pct: ' + rem_pct.inspect).debug if @debug
|
202
|
+
mapper(div, item[3], orientation: orientation)
|
203
|
+
|
204
|
+
#group_foot = Rexle::Element.new('div', attributes: {class: 'gfoot'})
|
205
|
+
#div.add group_foot
|
267
206
|
|
268
207
|
else
|
269
208
|
|
270
209
|
title, value, url, list, percent = item
|
271
210
|
|
272
|
-
factor = scale / (100 / percent.to_f)
|
273
211
|
|
274
212
|
if @debug then
|
275
|
-
puts 'scale: ' + scale.inspect
|
276
213
|
puts 'percent: ' + percent.inspect
|
277
|
-
puts 'factor: ' + factor.inspect
|
278
214
|
end
|
279
215
|
|
280
|
-
e = add_box(title, url, {}, ("c%02d" % factor).to_s[0..-2])
|
216
|
+
#e = add_box(title, url, {}, ("c%02d" % factor).to_s[0..-2])
|
217
|
+
e = add_box(title, url, {})
|
281
218
|
puts 'e: ' + e.inspect if @debug
|
282
219
|
|
283
220
|
end
|
@@ -287,12 +224,14 @@ EOF
|
|
287
224
|
|
288
225
|
if a3.any? then
|
289
226
|
|
290
|
-
|
291
|
-
|
227
|
+
style = "%s: %s%%; font-size: %s%%" % [ dimension, rem_pct.round,
|
228
|
+
rem_pct.round + 15]
|
229
|
+
doc3 = Rexle.new("<div id='box%s' class='%s' style='%s'/>" % \
|
230
|
+
[@counter, klass, style])
|
292
231
|
@counter += 1
|
293
232
|
|
294
|
-
|
295
|
-
|
233
|
+
puts ('_rem_pct: ' + rem_pct.inspect).debug if @debug
|
234
|
+
doc2 = mapper(doc3, a3, orientation: new_orientation, total: remainder)
|
296
235
|
doc.root.add doc2.root
|
297
236
|
|
298
237
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: treemap21
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
12lnvOZUZbofT7ctIMQL18INESoDYcmiH9r34KV6UCK9H/Ifm5CPKEYee8nilRM+
|
36
36
|
yIv4TcA8Psh7eTn7IAvLK4C0
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2021-05-
|
38
|
+
date: 2021-05-18 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: polyrex
|
@@ -57,6 +57,26 @@ dependencies:
|
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: 1.3.1
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: weblet
|
62
|
+
requirement: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0.3'
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.3.5
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.3'
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 0.3.5
|
60
80
|
description:
|
61
81
|
email: digital.robertson@gmail.com
|
62
82
|
executables: []
|
@@ -87,5 +107,5 @@ rubyforge_project:
|
|
87
107
|
rubygems_version: 2.7.10
|
88
108
|
signing_key:
|
89
109
|
specification_version: 4
|
90
|
-
summary:
|
110
|
+
summary: Treemapping gem which generates an HTML document.
|
91
111
|
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|