@@ -3,12 +3,12 @@ using DashCoreComponents
33using DashHtmlComponents
44using PlotlyJS, HTTP, JSON
55
6- app = dash (external_stylesheets = [" https://codepen.io/chriddyp/pen/bWLwgP.css" ])
6+ app = dash (external_stylesheets= [" https://codepen.io/chriddyp/pen/bWLwgP.css" ])
77
8- response= HTTP. get (" https://raw.githubusercontent.com/plotly/plotly.js/master/test/image/mocks/sankey_energy.json" )
9- data= JSON. parse (String (response. body))
8+ response = HTTP. get (" https://raw.githubusercontent.com/plotly/plotly.js/master/test/image/mocks/sankey_energy.json" )
9+ data = JSON. parse (String (response. body))
1010
11- app. layout = html_div () do
11+ app. layout = html_div () do
1212 dcc_graph (id= " graph" ),
1313 html_p (" Opacity" ),
1414 dcc_slider (id= " opacity" , min= 0 , max= 1 , value= 0.5 , step= 0.1 )
@@ -19,36 +19,36 @@ callback!(app, Output("graph", "figure"), Input("opacity", "value")) do val
1919 link = data[" data" ][1 ][" link" ]
2020
2121 node[" color" ] = [
22- c == " magenta" ?
23- string (" rbga(255,0,255," , val," )" ) :
22+ c == " magenta" ?
23+ string (" rbga(255,0,255," , val, " )" ) :
2424 replace (c, " 0.8" => val)
25- for c in node[" color" ]
25+ for c in node[" color" ]
2626 ]
2727
2828 link[" color" ] = [
29- node[" color" ][src+ 1 ] # account for 1 based index
29+ node[" color" ][src + 1 ] # account for 1 based index
3030 for src in link[" source" ]
3131 ]
3232
3333 fig = plot (
3434 sankey (
35- valueformat = " .0f" ,
36- valuesuffix = " TWh" ,
35+ valueformat= " .0f" ,
36+ valuesuffix= " TWh" ,
3737 # Define nodes
38- node = attr (
39- pad = 15 ,
40- thickness = 15 ,
41- line = attr (color = " black" , width = 0.5 ),
42- label = data[" data" ][1 ][" node" ][" label" ],
43- color = data[" data" ][1 ][" node" ][" color" ]
38+ node= attr (
39+ pad= 15 ,
40+ thickness= 15 ,
41+ line= attr (color= " black" , width= 0.5 ),
42+ label= data[" data" ][1 ][" node" ][" label" ],
43+ color= data[" data" ][1 ][" node" ][" color" ]
4444 ),
4545 # Add links
46- link = attr (
47- source = data[" data" ][1 ][" link" ][" source" ],
48- target = data[" data" ][1 ][" link" ][" target" ],
49- value = data[" data" ][1 ][" link" ][" value" ],
50- label = data[" data" ][1 ][" link" ][" label" ],
51- color = data[" data" ][1 ][" link" ][" color" ]
46+ link= attr (
47+ source= data[" data" ][1 ][" link" ][" source" ],
48+ target= data[" data" ][1 ][" link" ][" target" ],
49+ value= data[" data" ][1 ][" link" ][" value" ],
50+ label= data[" data" ][1 ][" link" ][" label" ],
51+ color= data[" data" ][1 ][" link" ][" color" ]
5252 )
5353 )
5454 )
0 commit comments