forked from d3noob's block: IVR from JSON
Using the suggestions for creating circles from VividD on StackOverflow.
forked from kmbenitez's block: Sankey modifications
license: mit |
forked from d3noob's block: IVR from JSON
Using the suggestions for creating circles from VividD on StackOverflow.
forked from kmbenitez's block: Sankey modifications
{"nodes":[{"curr_state_name":"Lookup State","curr_state_id":"236","call_flow":674,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":0,"name":"Lookup State"},{"curr_state_name":"Return","curr_state_id":"240","call_flow":666,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":1,"name":"Return"},{"curr_state_name":"Return","curr_state_id":"700","call_flow":684,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":2,"name":"Return"},{"curr_state_name":"script","curr_state_id":"702","call_flow":705,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":3,"name":"script"},{"curr_state_name":"Set list","curr_state_id":"704","call_flow":705,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":4,"name":"Set list"},{"curr_state_name":"Save 100s Press One","curr_state_id":"2220","call_flow":95284,"hangup_number":94264,"repeat_number":3881,"hanguprate":0.98929515973301,"repeatrate":0.040730867721758,"node":5,"name":"Save 100s Press One"},{"curr_state_name":"MX ","curr_state_id":"2224","call_flow":29,"hangup_number":29,"repeat_number":0,"hanguprate":1,"repeatrate":0,"node":6,"name":"MX "},{"curr_state_name":"Night and Weekend Auto Prism","curr_state_id":"2226","call_flow":80,"hangup_number":37,"repeat_number":21,"hanguprate":0.4625,"repeatrate":0.2625,"node":7,"name":"Night and Weekend Auto Prism"},{"curr_state_name":"Sending to Marchex ","curr_state_id":"2228","call_flow":52873,"hangup_number":51726,"repeat_number":896,"hanguprate":0.97830650804759,"repeatrate":0.01694626747111,"node":8,"name":"Sending to Marchex "},{"curr_state_name":"Time Condition","curr_state_id":"2230","call_flow":159950,"hangup_number":4,"repeat_number":0,"hanguprate":2.5007814942169e-5,"repeatrate":0,"node":9,"name":"Time Condition"},{"curr_state_name":"Press 5 for quote","curr_state_id":"2232","call_flow":132,"hangup_number":56,"repeat_number":77,"hanguprate":0.42424242424242,"repeatrate":0.58333333333333,"node":10,"name":"Press 5 for quote"},{"curr_state_name":"Disclaimer Hangup","curr_state_id":"2234","call_flow":7,"hangup_number":3,"repeat_number":0,"hanguprate":0.42857142857143,"repeatrate":0,"node":11,"name":"Disclaimer Hangup"},{"curr_state_name":"Hangup","curr_state_id":"2236","call_flow":2166,"hangup_number":2166,"repeat_number":0,"hanguprate":1,"repeatrate":0,"node":12,"name":"Hangup"},{"curr_state_name":"8888435186","curr_state_id":"2238","call_flow":23,"hangup_number":23,"repeat_number":0,"hanguprate":1,"repeatrate":0,"node":13,"name":"8888435186"},{"curr_state_name":"Time Condition 2","curr_state_id":"2506","call_flow":985571,"hangup_number":5,"repeat_number":0,"hanguprate":5.0732012204093e-6,"repeatrate":0,"node":14,"name":"Time Condition 2"},{"curr_state_name":"Late Night Script 8pm to 8am","curr_state_id":"2512","call_flow":47737,"hangup_number":44390,"repeat_number":8302,"hanguprate":0.92988667071663,"repeatrate":0.17391122190335,"node":15,"name":"Late Night Script 8pm to 8am"},{"curr_state_name":"Time Condition","curr_state_id":"2514","call_flow":1023286,"hangup_number":8,"repeat_number":0,"hanguprate":7.8179511886218e-6,"repeatrate":0,"node":16,"name":"Time Condition"},{"curr_state_name":"Press 5 for Best Auto ","curr_state_id":"2516","call_flow":2519,"hangup_number":700,"repeat_number":1224,"hanguprate":0.27788805081382,"repeatrate":0.48590710599444,"node":17,"name":"Press 5 for Best Auto "},{"curr_state_name":"Hangup","curr_state_id":"2520","call_flow":25386,"hangup_number":25386,"repeat_number":0,"hanguprate":1,"repeatrate":0,"node":18,"name":"Hangup"},{"curr_state_name":"Save 100s Press One","curr_state_id":"2526","call_flow":950554,"hangup_number":925875,"repeat_number":71396,"hanguprate":0.97403724564833,"repeatrate":0.075109883289114,"node":19,"name":"Save 100s Press One"},{"curr_state_name":"Return","curr_state_id":"2528","call_flow":684,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":20,"name":"Return"},{"curr_state_name":"MX ","curr_state_id":"2532","call_flow":37,"hangup_number":37,"repeat_number":0,"hanguprate":1,"repeatrate":0,"node":21,"name":"MX "},{"curr_state_name":"RP Fixed Rate 8888435186","curr_state_id":"2546","call_flow":630,"hangup_number":630,"repeat_number":0,"hanguprate":1,"repeatrate":0,"node":22,"name":"RP Fixed Rate 8888435186"},{"curr_state_name":"RP or MX","curr_state_id":"2548","call_flow":156,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":23,"name":"RP or MX"},{"curr_state_name":"Lookup State Code","curr_state_id":"2552","call_flow":630,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":24,"name":"Lookup State Code"},{"curr_state_name":"FL and MI to RP Variable Rate","curr_state_id":"2554","call_flow":630,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":25,"name":"FL and MI to RP Variable Rate"},{"curr_state_name":"Route to Buyer","curr_state_id":"2574","call_flow":684,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":26,"name":"Route to Buyer"},{"curr_state_name":"CID Change","curr_state_id":"2576","call_flow":684,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":27,"name":"CID Change"},{"curr_state_name":"Start","curr_state_id":"2580","call_flow":1028559,"hangup_number":4,"repeat_number":0,"hanguprate":3.8889358801974e-6,"repeatrate":0,"node":28,"name":"Start"},{"curr_state_name":"Marchex Off Hours","curr_state_id":"3068","call_flow":36,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":29,"name":"Marchex Off Hours"},{"curr_state_name":"Return","curr_state_id":"3072","call_flow":36,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":30,"name":"Return"},{"curr_state_name":"Marchex Excluded States","curr_state_id":"3074","call_flow":4,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":31,"name":"Marchex Excluded States"},{"curr_state_name":"RP Fixed Rate 8888435186","curr_state_id":"3102","call_flow":1,"hangup_number":1,"repeat_number":0,"hanguprate":1,"repeatrate":0,"node":32,"name":"RP Fixed Rate 8888435186"},{"curr_state_name":"RP Fixed Rate Restricted States","curr_state_id":"3108","call_flow":1,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":33,"name":"RP Fixed Rate Restricted States"},{"curr_state_name":"Marchex Auto Insurance 8882594922","curr_state_id":"3116","call_flow":36,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":34,"name":"Marchex Auto Insurance 8882594922"},{"curr_state_name":"Lookup State Code","curr_state_id":"3118","call_flow":36,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":35,"name":"Lookup State Code"},{"curr_state_name":"RP Fixed Rate 8888435186","curr_state_id":"3120","call_flow":1,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":36,"name":"RP Fixed Rate 8888435186"},{"curr_state_name":"Do You Have Auto Insurance","curr_state_id":"3280","call_flow":36,"hangup_number":8,"repeat_number":7,"hanguprate":0.22222222222222,"repeatrate":0.19444444444444,"node":37,"name":"Do You Have Auto Insurance"},{"curr_state_name":"Timed Conditional Insured ","curr_state_id":"3284","call_flow":12,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":38,"name":"Timed Conditional Insured "},{"curr_state_name":"Mcall Insured","curr_state_id":"3286","call_flow":9,"hangup_number":9,"repeat_number":0,"hanguprate":1,"repeatrate":0,"node":39,"name":"Mcall Insured"},{"curr_state_name":"Return","curr_state_id":"3288","call_flow":1,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":40,"name":"Return"},{"curr_state_name":"Mcall Uninsured","curr_state_id":"3292","call_flow":18,"hangup_number":18,"repeat_number":0,"hanguprate":1,"repeatrate":0,"node":41,"name":"Mcall Uninsured"},{"curr_state_name":"50 50 Split","curr_state_id":"3296","call_flow":24,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":42,"name":"50 50 Split"},{"curr_state_name":"Mcall Auto Insurance 8442319599 and 8444668164","curr_state_id":"3314","call_flow":36,"hangup_number":0,"repeat_number":0,"hanguprate":0,"repeatrate":0,"node":43,"name":"Mcall Auto Insurance 8442319599 and 8444668164"}],"links":[{"curr_state_name":"Lookup State","curr_state_id":"236","next_state_name":"Return","next_state_id":"240","forwarded_to":"","capturedigit_digit":"0","call_flow":"674","source":0,"target":1,"value":674},{"curr_state_name":"Return","curr_state_id":"240","next_state_name":"FL and MI to RP Variable Rate","next_state_id":"2554","forwarded_to":"","capturedigit_digit":"0","call_flow":"630","source":1,"target":25,"value":630},{"curr_state_name":"Return","curr_state_id":"240","next_state_name":"Marchex Auto Insurance 8882594922","next_state_id":"3116","forwarded_to":"","capturedigit_digit":"0","call_flow":"36","source":1,"target":34,"value":36},{"curr_state_name":"Return","curr_state_id":"700","next_state_name":"Route to Buyer","next_state_id":"2574","forwarded_to":"","capturedigit_digit":"0","call_flow":"684","source":2,"target":26,"value":684},{"curr_state_name":"script","curr_state_id":"702","next_state_name":"Return","next_state_id":"700","forwarded_to":"","capturedigit_digit":"0","call_flow":"705","source":3,"target":2,"value":705},{"curr_state_name":"Set list","curr_state_id":"704","next_state_name":"script","next_state_id":"702","forwarded_to":"","capturedigit_digit":"0","call_flow":"705","source":4,"target":3,"value":705},{"curr_state_name":"Save 100s Press One","curr_state_id":"2220","next_state_name":"Press 5 for quote","next_state_id":"2232","forwarded_to":"","capturedigit_digit":"1","call_flow":"61","source":5,"target":10,"value":61},{"curr_state_name":"Save 100s Press One","curr_state_id":"2220","next_state_name":"Hangup","next_state_id":"2236","forwarded_to":"","capturedigit_digit":"0","call_flow":"541","source":5,"target":12,"value":541},{"curr_state_name":"Save 100s Press One","curr_state_id":"2220","next_state_name":"Hangup","next_state_id":"2236","forwarded_to":"","capturedigit_digit":"7","call_flow":"418","source":5,"target":12,"value":418},{"curr_state_name":"Night and Weekend Auto Prism","curr_state_id":"2226","next_state_name":"MX ","next_state_id":"2224","forwarded_to":"","capturedigit_digit":"5","call_flow":"36","source":7,"target":6,"value":36},{"curr_state_name":"Night and Weekend Auto Prism","curr_state_id":"2226","next_state_name":"Hangup","next_state_id":"2236","forwarded_to":"","capturedigit_digit":"0","call_flow":"2","source":7,"target":12,"value":2},{"curr_state_name":"Night and Weekend Auto Prism","curr_state_id":"2226","next_state_name":"Hangup","next_state_id":"2236","forwarded_to":"","capturedigit_digit":"7","call_flow":"5","source":7,"target":12,"value":5},{"curr_state_name":"Sending to Marchex ","curr_state_id":"2228","next_state_name":"Night and Weekend Auto Prism","next_state_id":"2226","forwarded_to":"","capturedigit_digit":"1","call_flow":"73","source":8,"target":7,"value":73},{"curr_state_name":"Sending to Marchex ","curr_state_id":"2228","next_state_name":"Hangup","next_state_id":"2236","forwarded_to":"","capturedigit_digit":"0","call_flow":"1051","source":8,"target":12,"value":1051},{"curr_state_name":"Sending to Marchex ","curr_state_id":"2228","next_state_name":"Hangup","next_state_id":"2236","forwarded_to":"","capturedigit_digit":"7","call_flow":"23","source":8,"target":12,"value":23},{"curr_state_name":"Time Condition","curr_state_id":"2230","next_state_name":"Save 100s Press One","next_state_id":"2220","forwarded_to":"","capturedigit_digit":"0","call_flow":"120260","source":9,"target":5,"value":120260},{"curr_state_name":"Time Condition","curr_state_id":"2230","next_state_name":"Sending to Marchex ","next_state_id":"2228","forwarded_to":"","capturedigit_digit":"0","call_flow":"39686","source":9,"target":8,"value":39686},{"curr_state_name":"Press 5 for quote","curr_state_id":"2232","next_state_name":"Disclaimer Hangup","next_state_id":"2234","forwarded_to":"","capturedigit_digit":"7","call_flow":"10","source":10,"target":11,"value":10},{"curr_state_name":"Press 5 for quote","curr_state_id":"2232","next_state_name":"Hangup","next_state_id":"2236","forwarded_to":"","capturedigit_digit":"0","call_flow":"43","source":10,"target":12,"value":43},{"curr_state_name":"Press 5 for quote","curr_state_id":"2232","next_state_name":"8888435186","next_state_id":"2238","forwarded_to":"","capturedigit_digit":"5","call_flow":"23","source":10,"target":13,"value":23},{"curr_state_name":"Disclaimer Hangup","curr_state_id":"2234","next_state_name":"Hangup","next_state_id":"2236","forwarded_to":"","capturedigit_digit":"0","call_flow":"4","source":11,"target":12,"value":4},{"curr_state_name":"Time Condition 2","curr_state_id":"2506","next_state_name":"Late Night Script 8pm to 8am","next_state_id":"2512","forwarded_to":"","capturedigit_digit":"0","call_flow":"9527","source":14,"target":15,"value":9527},{"curr_state_name":"Time Condition 2","curr_state_id":"2506","next_state_name":"Save 100s Press One","next_state_id":"2526","forwarded_to":"","capturedigit_digit":"0","call_flow":"976039","source":14,"target":19,"value":976039},{"curr_state_name":"Late Night Script 8pm to 8am","curr_state_id":"2512","next_state_name":"Press 5 for Best Auto ","next_state_id":"2516","forwarded_to":"","capturedigit_digit":"1","call_flow":"154","source":15,"target":17,"value":154},{"curr_state_name":"Late Night Script 8pm to 8am","curr_state_id":"2512","next_state_name":"Hangup","next_state_id":"2520","forwarded_to":"","capturedigit_digit":"0","call_flow":"3017","source":15,"target":18,"value":3017},{"curr_state_name":"Late Night Script 8pm to 8am","curr_state_id":"2512","next_state_name":"Hangup","next_state_id":"2520","forwarded_to":"","capturedigit_digit":"7","call_flow":"176","source":15,"target":18,"value":176},{"curr_state_name":"Time Condition","curr_state_id":"2514","next_state_name":"Time Condition 2","next_state_id":"2506","forwarded_to":"","capturedigit_digit":"0","call_flow":"985571","source":16,"target":14,"value":985571},{"curr_state_name":"Time Condition","curr_state_id":"2514","next_state_name":"Late Night Script 8pm to 8am","next_state_id":"2512","forwarded_to":"","capturedigit_digit":"0","call_flow":"37707","source":16,"target":15,"value":37707},{"curr_state_name":"Press 5 for Best Auto ","curr_state_id":"2516","next_state_name":"Hangup","next_state_id":"2520","forwarded_to":"","capturedigit_digit":"0","call_flow":"972","source":17,"target":18,"value":972},{"curr_state_name":"Press 5 for Best Auto ","curr_state_id":"2516","next_state_name":"Hangup","next_state_id":"2520","forwarded_to":"","capturedigit_digit":"7","call_flow":"144","source":17,"target":18,"value":144},{"curr_state_name":"Press 5 for Best Auto ","curr_state_id":"2516","next_state_name":"Return","next_state_id":"2528","forwarded_to":"","capturedigit_digit":"5","call_flow":"703","source":17,"target":20,"value":703},{"curr_state_name":"Save 100s Press One","curr_state_id":"2526","next_state_name":"Press 5 for Best Auto ","next_state_id":"2516","forwarded_to":"","capturedigit_digit":"1","call_flow":"2461","source":19,"target":17,"value":2461},{"curr_state_name":"Save 100s Press One","curr_state_id":"2526","next_state_name":"Hangup","next_state_id":"2520","forwarded_to":"","capturedigit_digit":"0","call_flow":"19696","source":19,"target":18,"value":19696},{"curr_state_name":"Save 100s Press One","curr_state_id":"2526","next_state_name":"Hangup","next_state_id":"2520","forwarded_to":"","capturedigit_digit":"7","call_flow":"2522","source":19,"target":18,"value":2522},{"curr_state_name":"Return","curr_state_id":"2528","next_state_name":"CID Change","next_state_id":"2576","forwarded_to":"","capturedigit_digit":"0","call_flow":"684","source":20,"target":27,"value":684},{"curr_state_name":"RP or MX","curr_state_id":"2548","next_state_name":"MX ","next_state_id":"2532","forwarded_to":"","capturedigit_digit":"0","call_flow":"37","source":23,"target":21,"value":37},{"curr_state_name":"RP or MX","curr_state_id":"2548","next_state_name":"Lookup State Code","next_state_id":"2552","forwarded_to":"","capturedigit_digit":"0","call_flow":"119","source":23,"target":24,"value":119},{"curr_state_name":"Lookup State Code","curr_state_id":"2552","next_state_name":"Lookup State","next_state_id":"236","forwarded_to":"","capturedigit_digit":"0","call_flow":"630","source":24,"target":0,"value":630},{"curr_state_name":"FL and MI to RP Variable Rate","curr_state_id":"2554","next_state_name":"RP Fixed Rate 8888435186","next_state_id":"2546","forwarded_to":"","capturedigit_digit":"0","call_flow":"630","source":25,"target":22,"value":630},{"curr_state_name":"Route to Buyer","curr_state_id":"2574","next_state_name":"RP or MX","next_state_id":"2548","forwarded_to":"","capturedigit_digit":"0","call_flow":"137","source":26,"target":23,"value":137},{"curr_state_name":"Route to Buyer","curr_state_id":"2574","next_state_name":"Lookup State Code","next_state_id":"2552","forwarded_to":"","capturedigit_digit":"0","call_flow":"511","source":26,"target":24,"value":511},{"curr_state_name":"Route to Buyer","curr_state_id":"2574","next_state_name":"Lookup State Code","next_state_id":"3118","forwarded_to":"","capturedigit_digit":"0","call_flow":"36","source":26,"target":35,"value":36},{"curr_state_name":"CID Change","curr_state_id":"2576","next_state_name":"Set list","next_state_id":"704","forwarded_to":"","capturedigit_digit":"0","call_flow":"684","source":27,"target":4,"value":684},{"curr_state_name":"Start","curr_state_id":"2580","next_state_name":"Time Condition","next_state_id":"2514","forwarded_to":"","capturedigit_digit":"0","call_flow":"1028555","source":28,"target":16,"value":1028555},{"curr_state_name":"Marchex Off Hours","curr_state_id":"3068","next_state_name":"Return","next_state_id":"3072","forwarded_to":"","capturedigit_digit":"0","call_flow":"32","source":29,"target":30,"value":32},{"curr_state_name":"Marchex Off Hours","curr_state_id":"3068","next_state_name":"Marchex Excluded States","next_state_id":"3074","forwarded_to":"","capturedigit_digit":"0","call_flow":"4","source":29,"target":31,"value":4},{"curr_state_name":"Return","curr_state_id":"3072","next_state_name":"Mcall Auto Insurance 8442319599 and 8444668164","next_state_id":"3314","forwarded_to":"","capturedigit_digit":"0","call_flow":"36","source":30,"target":43,"value":36},{"curr_state_name":"Marchex Excluded States","curr_state_id":"3074","next_state_name":"Return","next_state_id":"3072","forwarded_to":"","capturedigit_digit":"0","call_flow":"4","source":31,"target":30,"value":4},{"curr_state_name":"RP Fixed Rate Restricted States","curr_state_id":"3108","next_state_name":"RP Fixed Rate 8888435186","next_state_id":"3102","forwarded_to":"","capturedigit_digit":"0","call_flow":"1","source":33,"target":32,"value":1},{"curr_state_name":"Marchex Auto Insurance 8882594922","curr_state_id":"3116","next_state_name":"Marchex Off Hours","next_state_id":"3068","forwarded_to":"","capturedigit_digit":"0","call_flow":"36","source":34,"target":29,"value":36},{"curr_state_name":"Lookup State Code","curr_state_id":"3118","next_state_name":"Lookup State","next_state_id":"236","forwarded_to":"","capturedigit_digit":"0","call_flow":"36","source":35,"target":0,"value":36},{"curr_state_name":"RP Fixed Rate 8888435186","curr_state_id":"3120","next_state_name":"RP Fixed Rate Restricted States","next_state_id":"3108","forwarded_to":"","capturedigit_digit":"0","call_flow":"1","source":36,"target":33,"value":1},{"curr_state_name":"Do You Have Auto Insurance","curr_state_id":"3280","next_state_name":"Timed Conditional Insured ","next_state_id":"3284","forwarded_to":"","capturedigit_digit":"1","call_flow":"12","source":37,"target":38,"value":12},{"curr_state_name":"Do You Have Auto Insurance","curr_state_id":"3280","next_state_name":"Return","next_state_id":"3288","forwarded_to":"","capturedigit_digit":"0","call_flow":"1","source":37,"target":40,"value":1},{"curr_state_name":"Do You Have Auto Insurance","curr_state_id":"3280","next_state_name":"Mcall Uninsured","next_state_id":"3292","forwarded_to":"","capturedigit_digit":"2","call_flow":"15","source":37,"target":41,"value":15},{"curr_state_name":"Timed Conditional Insured ","curr_state_id":"3284","next_state_name":"Mcall Insured","next_state_id":"3286","forwarded_to":"","capturedigit_digit":"0","call_flow":"9","source":38,"target":39,"value":9},{"curr_state_name":"Timed Conditional Insured ","curr_state_id":"3284","next_state_name":"Mcall Uninsured","next_state_id":"3292","forwarded_to":"","capturedigit_digit":"0","call_flow":"3","source":38,"target":41,"value":3},{"curr_state_name":"Return","curr_state_id":"3288","next_state_name":"RP Fixed Rate 8888435186","next_state_id":"3120","forwarded_to":"","capturedigit_digit":"0","call_flow":"1","source":40,"target":36,"value":1},{"curr_state_name":"50 50 Split","curr_state_id":"3296","next_state_name":"Do You Have Auto Insurance","next_state_id":"3280","forwarded_to":"","capturedigit_digit":"0","call_flow":"24","source":42,"target":37,"value":24},{"curr_state_name":"Mcall Auto Insurance 8442319599 and 8444668164","curr_state_id":"3314","next_state_name":"Do You Have Auto Insurance","next_state_id":"3280","forwarded_to":"","capturedigit_digit":"0","call_flow":"12","source":43,"target":37,"value":12},{"curr_state_name":"Mcall Auto Insurance 8442319599 and 8444668164","curr_state_id":"3314","next_state_name":"50 50 Split","next_state_id":"3296","forwarded_to":"","capturedigit_digit":"0","call_flow":"24","source":43,"target":42,"value":24}]} |
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<title>SANKEY Experiment</title> | |
<style> | |
.node rect { | |
cursor: move; | |
fill-opacity: .9; | |
shape-rendering: crispEdges; | |
} | |
.node text { | |
pointer-events: none; | |
text-shadow: 0 1px 0 #fff; | |
} | |
.link { | |
fill: none; | |
stroke: #000; | |
stroke-opacity: .2; | |
} | |
.link:hover { | |
stroke-opacity: .5; | |
} | |
</style> | |
<body> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<script src="https://d3js.org/d3-scale-chromatic.v1.min.js"></script> | |
<script src="sankey.js"></script> | |
<script> | |
var units = "calls"; | |
// set the dimensions and margins of the graph | |
var margin = {top: 10, right: 10, bottom: 10, left: 10}, | |
width = 2700 - margin.left - margin.right, | |
height = 2000 - margin.top - margin.bottom; | |
var formatNumber = d3.format(",.0f"), // zero decimal places | |
format = function(d) { return formatNumber(d) + " " + units; }, | |
formatPercent = d3.format(",.5f"), | |
ratetoPercent = function(d) { return formatPercent(100 * d) + "%"; }; | |
// append the svg object to the body of the page | |
var svg = d3.select("body").append("svg") | |
.attr("width", width + margin.left + margin.right) | |
.attr("height", height + margin.top + margin.bottom) | |
.append("g") | |
.attr("transform", | |
"translate(" + margin.left + "," + margin.top + ")"); | |
// Set the sankey diagram properties | |
var sankey = d3.sankey() | |
.nodeWidth(10) | |
.nodePadding(15) | |
.size([width, height]); | |
var path = function(d) { | |
return linkVertical({"x":d.source.x + sankey.nodeWidth() / 2, | |
"y":d.source.y + d.source.dy / 2}, | |
{"x":d.target.x + sankey.nodeWidth() / 2, | |
"y":d.target.y + d.target.dy / 2}); | |
}; | |
// Creates a curved (diagonal) path from parent to the child nodes | |
function linkHorizontal(source, target) { | |
return "M" + source.x + "," + source.y | |
+ "C" + source.x + "," + (source.y + target.y) / 2 | |
+ " " + target.x + "," + (source.y + target.y) / 2 | |
+ " " + target.x + "," + target.y; | |
} | |
function linkVertical(source, target) { | |
return "M" + source.x + "," + source.y | |
+ "C" + (source.x + target.x) / 2 + "," + source.y | |
+ " " + (source.x + target.x) / 2 + "," + target.y | |
+ " " + target.x + "," + target.y; | |
} | |
//var path = sankey.link(); | |
// load the data | |
d3.json("albany04.json", function(error, graph) { | |
sankey | |
.nodes(graph.nodes) | |
.links(graph.links) | |
.layout(56); | |
// add in the links | |
var link = svg.append("g").selectAll(".link") | |
.data(graph.links) | |
.enter().append("path") | |
.attr("class", "link") | |
.attr("d", path) | |
.style("stroke-width", function(d) { return Math.max(1, Math.sqrt(d.dy)); }) | |
.sort(function(a, b) { return b.dy - a.dy; }); | |
// add the link titles | |
link.append("title") | |
.text(function(d) { | |
return d.source.name + " → " + | |
d.target.name + "\n" + format(d.value) + | |
(d.capturedigit_digit == "0" ? | |
"" : ("\nKeypress: " + d.capturedigit_digit)); }); | |
// add in the nodes | |
var node = svg.append("g").selectAll(".node") | |
.data(graph.nodes) | |
.enter().append("g") | |
.attr("class", "node") | |
.attr("transform", function(d) { | |
return "translate(" + d.x + "," + d.y + ")"; }) | |
.call(d3.drag() | |
.subject(function(d) { | |
return d; | |
}) | |
.on("start", function() { | |
this.parentNode.appendChild(this); | |
}) | |
.on("drag", dragmove)); | |
// add the circles for the nodes | |
node.append("circle") | |
.attr("cx", sankey.nodeWidth()/2) | |
.attr("cy", function(d) { | |
return d.dy/2; | |
}) | |
.attr("r", function(d) { | |
return Math.sqrt(d.dy); | |
}) | |
.style("fill", function(d) { | |
return d.color = d3.interpolateRdYlGn(1 - d.hanguprate); }) | |
.style("stroke", function(d) { | |
return d3.rgb(d.color).darker(2); }) | |
.append("title") | |
.text(function(d) { | |
return d.name + "\n" + format(d.value) + "\n" + ratetoPercent(d.repeatrate) +" repeated\n" + ratetoPercent(d.hanguprate) + " hung up";}); | |
// add in the title for the nodes | |
node.append("text") | |
.attr("x", -6) | |
.attr("y", function(d) { return d.dy / 2; }) | |
.attr("dy", ".35em") | |
.attr("text-anchor", "end") | |
.attr("transform", null) | |
.text(function(d) { return d.name; }) | |
.filter(function(d) { return d.x < width / 2; }) | |
.attr("x", function(d) { return 6 + sankey.nodeWidth() + Math.sqrt(d.dy);}) | |
.attr("text-anchor", "start"); | |
// the function for moving the nodes | |
function dragmove(d) { | |
d3.select(this) | |
.attr("transform", | |
"translate(" | |
+ d.x + "," | |
+ (d.y = Math.max( | |
0, Math.min(height - d.dy, d3.event.y)) | |
) + ")"); | |
sankey.relayout(); | |
link.attr("d", path); | |
} | |
}); | |
</script> | |
</body> | |
d3.sankey = function() { | |
var sankey = {}, | |
nodeWidth = 24, | |
nodePadding = 8, | |
size = [1, 1], | |
nodes = [], | |
links = []; | |
sankey.nodeWidth = function(_) { | |
if (!arguments.length) return nodeWidth; | |
nodeWidth = +_; | |
return sankey; | |
}; | |
sankey.nodePadding = function(_) { | |
if (!arguments.length) return nodePadding; | |
nodePadding = +_; | |
return sankey; | |
}; | |
sankey.nodes = function(_) { | |
if (!arguments.length) return nodes; | |
nodes = _; | |
return sankey; | |
}; | |
sankey.links = function(_) { | |
if (!arguments.length) return links; | |
links = _; | |
return sankey; | |
}; | |
sankey.size = function(_) { | |
if (!arguments.length) return size; | |
size = _; | |
return sankey; | |
}; | |
sankey.layout = function(iterations) { | |
computeNodeLinks(); | |
computeNodeValues(); | |
computeNodeBreadths(); | |
computeNodeDepths(iterations); | |
computeLinkDepths(); | |
return sankey; | |
}; | |
sankey.relayout = function() { | |
computeLinkDepths(); | |
return sankey; | |
}; | |
sankey.link = function() { | |
var curvature = .5; | |
function link(d) { | |
var x0 = d.source.x + d.source.dx, | |
x1 = d.target.x, | |
xi = d3.interpolateNumber(x0, x1), | |
x2 = xi(curvature), | |
x3 = xi(1 - curvature), | |
y0 = d.source.y + d.sy + d.dy / 2, | |
y1 = d.target.y + d.ty + d.dy / 2; | |
return "M" + x0 + "," + y0 | |
+ "C" + x2 + "," + y0 | |
+ " " + x3 + "," + y1 | |
+ " " + x1 + "," + y1; | |
} | |
link.curvature = function(_) { | |
if (!arguments.length) return curvature; | |
curvature = +_; | |
return link; | |
}; | |
return link; | |
}; | |
// Populate the sourceLinks and targetLinks for each node. | |
// Also, if the source and target are not objects, assume they are indices. | |
function computeNodeLinks() { | |
nodes.forEach(function(node) { | |
node.sourceLinks = []; | |
node.targetLinks = []; | |
}); | |
links.forEach(function(link) { | |
var source = link.source, | |
target = link.target; | |
if (typeof source === "number") source = link.source = nodes[link.source]; | |
if (typeof target === "number") target = link.target = nodes[link.target]; | |
source.sourceLinks.push(link); | |
target.targetLinks.push(link); | |
}); | |
} | |
// Compute the value (size) of each node by summing the associated links. | |
function computeNodeValues() { | |
nodes.forEach(function(node) { | |
node.value = Math.max( | |
d3.sum(node.sourceLinks, value), | |
d3.sum(node.targetLinks, value) | |
); | |
}); | |
} | |
// Iteratively assign the breadth (x-position) for each node. | |
// Nodes are assigned the maximum breadth of incoming neighbors plus one; | |
// nodes with no incoming links are assigned breadth zero, while | |
// nodes with no outgoing links are assigned the maximum breadth. | |
function computeNodeBreadths() { | |
var remainingNodes = nodes, | |
nextNodes, | |
x = 0; | |
while (remainingNodes.length) { | |
nextNodes = []; | |
remainingNodes.forEach(function(node) { | |
node.x = x; | |
node.dx = nodeWidth; | |
node.sourceLinks.forEach(function(link) { | |
if (nextNodes.indexOf(link.target) < 0) { | |
nextNodes.push(link.target); | |
} | |
}); | |
}); | |
remainingNodes = nextNodes; | |
++x; | |
} | |
// | |
moveSinksRight(x); | |
scaleNodeBreadths((size[0] - nodeWidth) / (x - 1)); | |
} | |
function moveSourcesRight() { | |
nodes.forEach(function(node) { | |
if (!node.targetLinks.length) { | |
node.x = d3.min(node.sourceLinks, function(d) { return d.target.x; }) - 1; | |
} | |
}); | |
} | |
function moveSinksRight(x) { | |
nodes.forEach(function(node) { | |
if (!node.sourceLinks.length) { | |
node.x = x - 1; | |
} | |
}); | |
} | |
function scaleNodeBreadths(kx) { | |
nodes.forEach(function(node) { | |
node.x *= kx; | |
}); | |
} | |
function computeNodeDepths(iterations) { | |
var nodesByBreadth = d3.nest() | |
.key(function(d) { return d.x; }) | |
.sortKeys(d3.ascending) | |
.entries(nodes) | |
.map(function(d) { return d.values; }); | |
// | |
initializeNodeDepth(); | |
resolveCollisions(); | |
for (var alpha = 1; iterations > 0; --iterations) { | |
relaxRightToLeft(alpha *= .99); | |
resolveCollisions(); | |
relaxLeftToRight(alpha); | |
resolveCollisions(); | |
} | |
function initializeNodeDepth() { | |
var ky = d3.min(nodesByBreadth, function(nodes) { | |
return (size[1] - (nodes.length - 1) * nodePadding) / d3.sum(nodes, value); | |
}); | |
nodesByBreadth.forEach(function(nodes) { | |
nodes.forEach(function(node, i) { | |
node.y = i; | |
node.dy = node.value * ky; | |
}); | |
}); | |
links.forEach(function(link) { | |
link.dy = link.value * ky; | |
}); | |
} | |
function relaxLeftToRight(alpha) { | |
nodesByBreadth.forEach(function(nodes, breadth) { | |
nodes.forEach(function(node) { | |
if (node.targetLinks.length) { | |
var y = d3.sum(node.targetLinks, weightedSource) / d3.sum(node.targetLinks, value); | |
node.y += (y - center(node)) * alpha; | |
} | |
}); | |
}); | |
function weightedSource(link) { | |
return center(link.source) * link.value; | |
} | |
} | |
function relaxRightToLeft(alpha) { | |
nodesByBreadth.slice().reverse().forEach(function(nodes) { | |
nodes.forEach(function(node) { | |
if (node.sourceLinks.length) { | |
var y = d3.sum(node.sourceLinks, weightedTarget) / d3.sum(node.sourceLinks, value); | |
node.y += (y - center(node)) * alpha; | |
} | |
}); | |
}); | |
function weightedTarget(link) { | |
return center(link.target) * link.value; | |
} | |
} | |
function resolveCollisions() { | |
nodesByBreadth.forEach(function(nodes) { | |
var node, | |
dy, | |
y0 = 0, | |
n = nodes.length, | |
i; | |
// Push any overlapping nodes down. | |
nodes.sort(ascendingDepth); | |
for (i = 0; i < n; ++i) { | |
node = nodes[i]; | |
dy = y0 - node.y; | |
if (dy > 0) node.y += dy; | |
y0 = node.y + node.dy + nodePadding; | |
} | |
// If the bottommost node goes outside the bounds, push it back up. | |
dy = y0 - nodePadding - size[1]; | |
if (dy > 0) { | |
y0 = node.y -= dy; | |
// Push any overlapping nodes back up. | |
for (i = n - 2; i >= 0; --i) { | |
node = nodes[i]; | |
dy = node.y + node.dy + nodePadding - y0; | |
if (dy > 0) node.y -= dy; | |
y0 = node.y; | |
} | |
} | |
}); | |
} | |
function ascendingDepth(a, b) { | |
return a.y - b.y; | |
} | |
} | |
function computeLinkDepths() { | |
nodes.forEach(function(node) { | |
node.sourceLinks.sort(ascendingTargetDepth); | |
node.targetLinks.sort(ascendingSourceDepth); | |
}); | |
nodes.forEach(function(node) { | |
var sy = 0, ty = 0; | |
node.sourceLinks.forEach(function(link) { | |
link.sy = sy; | |
sy += link.dy; | |
}); | |
node.targetLinks.forEach(function(link) { | |
link.ty = ty; | |
ty += link.dy; | |
}); | |
}); | |
function ascendingSourceDepth(a, b) { | |
return a.source.y - b.source.y; | |
} | |
function ascendingTargetDepth(a, b) { | |
return a.target.y - b.target.y; | |
} | |
} | |
function center(node) { | |
return node.y + node.dy / 2; | |
} | |
function value(link) { | |
return link.value; | |
} | |
return sankey; | |
}; |
{ | |
"nodes":[ | |
{"node":0,"name":"node0","otherstat":"hello","hanguprate":0.67}, | |
{"node":1,"name":"node1","otherstat":"blah","hanguprate":0.23}, | |
{"node":2,"name":"node2","otherstat":"near","hanguprate":0.15}, | |
{"node":3,"name":"node3","otherstat":"far","hanguprate":0.99}, | |
{"node":4,"name":"node4","otherstat":"another","hanguprate":0.22} | |
], | |
"links":[ | |
{"source":0,"target":2,"value":2}, | |
{"source":1,"target":2,"value":2}, | |
{"source":1,"target":3,"value":2}, | |
{"source":0,"target":4,"value":2}, | |
{"source":2,"target":3,"value":2}, | |
{"source":2,"target":4,"value":2}, | |
{"source":3,"target":4,"value":4} | |
]} |