Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colors on sunburst example are broken #45

Merged
merged 1 commit into from Dec 30, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions vrepl/resources/samples/sunburst.clj
Expand Up @@ -4,19 +4,19 @@
[c2.maths :only [sqrt sin cos Tau]] ;;Life's short, don't waste it writing 2*Pi
[c2.svg :only [arc]]
[c2.layout.partition :only [partition]]

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wiping whitespace here

[vomnibus.d3 :only [flare]]
[vomnibus.d3-color :only [Categorical-20]]))

(let [radius 270
;;Partition will give us entries for every node;
;;we only want slices, so filter out the root node.
slices (filter #(-> % :partition :depth (not= 0))
slices (filter #(-> % :partition :depth (not= 0))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wiping whitespace here

(partition flare :value :size
:size [Tau (* radius radius)]))
;;TODO: Rework partition to include reference to parent so we can match D3's coloring scheme?
color-scale (apply hash-map (interleave
(into #{} (map :name (filter :children slices)))
(into #{} (map #(keyword (:name %)) slices))
(flatten (repeat Categorical-20))))]

[:svg {:width (* 2 radius) :height (* 2 radius)}
Expand All @@ -30,5 +30,5 @@
:outer-radius (sqrt (+ y dy))
:start-angle x
:end-angle (+ x dx))
:fill "white"}]]))]]
:fill ((keyword name) color-scale)}]]))]]
)