D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
BenHeubl
Full window
Github gist
test_data_function_broadway
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } svg { width:100%; height: 100% } </style> </head> <body> <button id="button1">Click</button> <script> // Feel free to change or delete any of the code you see! var svg = d3.select("body").append("svg") .attr({x: 100, y: 10, width: 700, height: 480}) .append("g").classed("main", true) svg.selectAll(".dots").data(d3.range(1, 52)).enter() .append("circle").classed("dots", true) .attr("cx", function (d, i) { return i*10}) .attr("cy", function (d, i) { return i*10}) .attr("r", 5) function update() { d3.selectAll(".dots") .transition() .duration(1000) .attr("cx", function (d, i) { return i*5}) .attr("cy", function (d, i) { return i*5}) } d3.select("#button1").on("click", update) //////////// var datas = []; var array = d3.range(1, 52); function pf (v, a, b) { return (v + 2) + (v*a) + (v*oo); } var pp = 10; var oo = 20; array.forEach(function(d, i) { datas.push({x: i, y: pf(d, pp, oo)}) }) console.log(datas) //////////// var HighestactorUlmerscore = 200 ; // a var Ulmerscore = 100 ; // b var Seatsintheater = 1500 ; // c var Weekofyear = 30 ; // d var Originalwork = 1 ; // e var Musical = 1 ; // f var Castsize = 45 ; // g var Disney = 0 ; // h var Basedonamovie = 0 ; // i var NYT = 1 ; // j var USA = 4 ; // k var majorTonyawards = 3 ; // l var Iscomedy = 1 ; // m var Isdrama = 1 ; // n var Past = 1 ; // o var R; // predictor function call predictor(HighestactorUlmerscore , Ulmerscore , Seatsintheater , Weekofyear , Originalwork , Musical , Castsize , Disney , Basedonamovie , NYT , USA , majorTonyawards , Iscomedy , Isdrama , Past) function predictor ( HighestactorUlmerscore, Ulmerscore, Seatsintheater, Weekofyear, Originalwork , Musical , Castsize , Disney , Basedonamovie , NYT , USA , majorTonyawards , Iscomedy , Isdrama , Past) { var PropSellout2 = 1/(1+(Math.exp(-(-(0.0042183*HighestactorUlmerscore)+(0.0039907*Ulmerscore)+(0.0000626*(Math.pow(HighestactorUlmerscore,2)))+(0.00000812*(Math.pow(Ulmerscore,2)))-(0.0007982*Seatsintheater)+(0.0419669*((Weekofyear==47?1:0)))+(1.041139*(((Weekofyear==52?(6/7):(Math.pow(Weekofyear==53?3/7:0))),2)))-(0.1213413*Weekofyear)+(0.0129541*(Math.pow(Weekofyear,2)))-(0.0003998*(Math.pow(Weekofyear,3)))+(0.00000373*(Math.pow(Weekofyear,4)))-(0.4756087*Weekofyear)-(3.885171*Musical)-(0.092289*Castsize*Musical)+(1.883142*Disney)-(0.0162975*Basedonamovie)+(0.0839098*Castsize)+(0.1854669*NYT)-(0.8336684*(1-NYT))+(0.2028874*Musical*USA)+(0.1258541*NYT*Musical)+(0.3561441*Musical*(1-NYT))-(0.470837*(Math.log(Castsize)))+(1.802581*Musical*(Math.log(Castsize)))+(1.217256*(Math.log(majorTonyawards)))-(0.5184693*Musical*(Math.log(majorTonyawards+1)))-(0.1466195*Iscomedy)-(0.157074*Isdrama)+(0.0150286*(Math.log(Past+1)))-1.9122703)))); // console.log(PropSellout2) // 1/(1+(EXP(-(-(0.0042183*A2)+(0.0039907*B2)+(0.0000626*(A2^2))+(0.00000812*(B2^2))-(0.0007982*C2)+(0.0419669*(IF(D2=47,1,0)))+(1.041139*((IF(D2=52,(6/7),IF(D2=53,3/7,0)))^2))-(0.1213413*D2)+(0.0129541*(D2^2))-(0.0003998*(D2^3))+(0.00000373*(D2^4))-(0.4756087*E2)-(3.885171*F2)-(0.092289*G2*F2)+(1.883142*H2)-(0.0162975*I2)+(0.0839098*G2)+(0.1854669*J2)-(0.8336684*(1-J2))+(0.2028874*F2*K2)+(0.1258541*J2*F2)+(0.3561441*F2*(1-J2))-(0.470837*(LN(G2)))+(1.802581*F2*(LN(G2)))+(1.217256*(LN(L2)))-(0.5184693*F2*(LN(L2+1)))-(0.1466195*M2)-(0.157074*N2)+(0.0150286*(LN(O2+1)))-1.9122703)))) } // end of predictor function </script> </body>
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js