Skip to content

Commit d21e0af

Browse files
fix NaN in radial layout
1 parent 0e21515 commit d21e0af

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

samples/twitterbuzz/src/twitterbuzz/layout.cljs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
[mentions-data]
4646
(let [mentions #(rad/get-mentions mentions-data %)
4747
weights (rad/weights
48-
(into #{} (mapcat mentions (keys mentions-data)))
48+
(into (set (roots mentions-data)) (mapcat mentions (keys mentions-data)))
4949
mentions)]
5050
{:mentions mentions-data
5151
:locs (-> (rad/layout (roots mentions-data) weights mentions)

samples/twitterbuzz/src/twitterbuzz/radial.cljs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
(layout nodes weight-fn child-fn 1 0 360 #{}))
5656
([nodes weight-fn child-fn radius a1 a2 seen]
5757
(let [slice (- a2 a1)
58-
total-weight (reduce + (map weight-fn nodes))
58+
total-weight (reduce + (map #(or (weight-fn %)
59+
(throw (str "No weight for " %))) nodes))
5960
seen (into seen nodes)]
6061
(loop [m {}
6162
c1 a1

0 commit comments

Comments
 (0)