treemap21 0.1.0 → 0.1.1
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/treemap21.rb +27 -13
- metadata +1 -1
- 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: 9825a658dbeae9c6fb7f654e5143cf31f2c2d293336be852fceb8fd750d28349
|
4
|
+
data.tar.gz: c31d5ec01707166babfb0b6d2ed7fa5e100d522cf6b6f70cc79a7bdb6d6006bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa4c065777f472807dd2d166fbcc3bbc9c39a911f9aed9d8d575550c9b38d691473434b647204b3e4e0548b61597db085d3429c4467658d15481912308b4168f
|
7
|
+
data.tar.gz: 8d1b5af64e797c1daab98a0a8636920678f6de19e58c1ddb89dd1b96447b00d130cf3d0682ef3a397a5939fac63df4c25d9337988ce9d3fd6f2aff6f49513ecc
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/treemap21.rb
CHANGED
@@ -25,20 +25,23 @@ class Treemap21
|
|
25
25
|
<head>
|
26
26
|
<style>
|
27
27
|
|
28
|
-
.cbox, .long, .cbox1 {
|
28
|
+
.cbox, .long, .cbox1, .cbox1 a {
|
29
29
|
width: 100%;
|
30
30
|
height: 100%;
|
31
31
|
}
|
32
32
|
.cbox1 ~.long, .cbox1 {
|
33
33
|
float: left;
|
34
34
|
}
|
35
|
-
.cbox1 {
|
35
|
+
.cbox1, .cbox1 a {
|
36
36
|
display: flex;
|
37
37
|
justify-content: center;
|
38
38
|
align-items: center;
|
39
39
|
}
|
40
40
|
|
41
|
-
.cbox1
|
41
|
+
.cbox1 a { text-decoration: none; color: #010; font-family: helvetica, arial}
|
42
|
+
.cbox1 a:hover { background-color: rgba(255,255,255,0.2); color: #902}
|
43
|
+
|
44
|
+
.cbox1 span { background-color: transparent; }
|
42
45
|
|
43
46
|
.c10 {font-size: 8em}
|
44
47
|
.c9 {font-size: 7.5em}
|
@@ -46,9 +49,9 @@ class Treemap21
|
|
46
49
|
.c7 {font-size: 5.0em}
|
47
50
|
.c6 {font-size: 4.9em}
|
48
51
|
.c5 {font-size: 4.5em}
|
49
|
-
.c4 {font-size: 3.
|
50
|
-
.c3 {font-size: 2.
|
51
|
-
.c2 {font-size:
|
52
|
+
.c4 {font-size: 3.6em}
|
53
|
+
.c3 {font-size: 2.6em}
|
54
|
+
.c2 {font-size: 2.4em}
|
52
55
|
.c1 {font-size: 1.6em}
|
53
56
|
.c0 {font-size: 1.1em}
|
54
57
|
|
@@ -66,15 +69,25 @@ EOF
|
|
66
69
|
|
67
70
|
private
|
68
71
|
|
69
|
-
def add_box(text, attr={}, cfont)
|
72
|
+
def add_box(text, url=nil, attr={}, cfont)
|
70
73
|
|
71
74
|
a = attr.map {|key, value| "%s: %s" % [key, value]}
|
72
75
|
h = {class: 'cbox1 ' + cfont, style: a.join('; ')}
|
73
76
|
span = Rexle::Element.new('span', value: text)
|
74
77
|
doc = Rexle::Element.new('div', attributes: h)
|
75
|
-
doc.root.add span
|
76
|
-
doc.root
|
77
78
|
|
79
|
+
|
80
|
+
if url then
|
81
|
+
anchor = Rexle::Element.new('a', attributes: {href: url})
|
82
|
+
anchor.root.add span
|
83
|
+
doc.root.add anchor.root
|
84
|
+
else
|
85
|
+
doc.root.add span
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
doc.root
|
90
|
+
|
78
91
|
end
|
79
92
|
|
80
93
|
def mapper(doc, a, orientation: :landscape, total: 100)
|
@@ -95,9 +108,9 @@ EOF
|
|
95
108
|
bgcolor = 3.times.map { rand(60..250).to_s(16) }.join
|
96
109
|
|
97
110
|
# find the largest box
|
98
|
-
a2 = a.sort_by
|
111
|
+
a2 = a.sort_by {|_, percent, _| percent}.reverse
|
99
112
|
puts 'a2.first: ' + a2.first.inspect if @debug
|
100
|
-
title, percent = a2.first
|
113
|
+
title, percent, url = a2.first
|
101
114
|
|
102
115
|
remainder = total - percent
|
103
116
|
# how much space does the largest box take?
|
@@ -119,7 +132,7 @@ EOF
|
|
119
132
|
dimension => rem.round.to_s + '%'
|
120
133
|
}
|
121
134
|
|
122
|
-
e = add_box(title, style, ("c%02d" % percent).to_s[0..-2])
|
135
|
+
e = add_box(title, url, style, ("c%02d" % percent).to_s[0..-2])
|
123
136
|
puts 'e: ' + e.inspect if @debug
|
124
137
|
|
125
138
|
doc.root.add e
|
@@ -130,7 +143,8 @@ EOF
|
|
130
143
|
doc3 = Rexle.new("<div class='%s' style='%s: %s%%'/>" % [klass, dim2,
|
131
144
|
rem2.round.to_s])
|
132
145
|
|
133
|
-
doc2 = mapper(doc3, a2[1..-1], orientation: new_orientation,
|
146
|
+
doc2 = mapper(doc3, a2[1..-1], orientation: new_orientation,
|
147
|
+
total: remainder)
|
134
148
|
|
135
149
|
doc.root.add doc2.root
|
136
150
|
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|