Created
November 22, 2022 11:23
-
-
Save otfrom/e5fd83a749d4852fc0119b96fddefc69 to your computer and use it in GitHub Desktop.
Converting some datasets (badly) into a sankey chart using plotly and clerk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(let [links (tc/dataset | |
[{:source 0 :target 2 :value 8} | |
{:source 1 :target 3 :value 4} | |
{:source 0 :target 4 :value 2} | |
{:source 2 :target 5 :value 8} | |
{:source 3 :target 5 :value 4} | |
{:source 3 :target 5 :value 2}]) | |
nodes (tc/dataset {:label ["red" "orange" "yellow" "green" "blue" "violet"] | |
:color ["red" "orange" "yellow" "green" "blue" "violet"]})] | |
(clerk/plotly | |
{:clerk/width :full} | |
{:data [{:type "sankey" | |
:orientation "h" | |
:valueformat ".0f" | |
:node {:pad 15 | |
:thickness 30 | |
:line {:color "black" :width 0.5} | |
:label (into [] (nodes :label)) | |
:color (into [] (nodes :color))} | |
:link {:source (into [] (links :source)) | |
:target (into [] (links :target)) | |
:value (into [] (links :value))}}] | |
:layout {:title "Basic Sankey" | |
:width 1024 | |
:height 1024 | |
:font {:size 10}} | |
:config {:displayModeBar false | |
:displayLogo false}})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment