D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
BenHeubl
Full window
Github gist
excel_function_BW2
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> <div id="result"></div> <script> var weekly_av_2015_16 = 907573.9; var weeklystde_2015_16 = 479660.8; // Original setup // 200 // 100 // 1500 // 30 // 1 // 1 // 45 // 0 // 0 // 1 // 4 // 3 // 0 // 0 // 1 var A2 = 200 ; var B2 = 100 ; var C2 = 1500 ; var D2 = 30 ; var E2 = 1; var F2 = 1 ; var G2 = 45 ; var H2 = 0 ; var I2 = 0 ; var J2 = 1 ; var K2 = 4 ; var L2 = 3 ; var M2 = 0 ; var N2 = 0 ; var O2 = 1 ; var R; // predictor function call predictor(A2 , B2 , C2 , D2 , E2 , F2 , G2 , H2 , I2 , J2 , K2 , L2 , M2 , N2 , O2, weekly_av_2015_16, weeklystde_2015_16) function predictor (A2 , B2 , C2 , D2 , E2 , F2 , G2 , H2 , I2 , J2 , K2 , L2 , M2 , N2 , O2 , weekly_av_2015_16, weeklystde_2015_16) { ProbSellout = 1/ ( 1+ ( Math.exp( -( -(0.0042183*A2) +(0.0039907*B2) +(0.0000626*(Math.pow(A2, 2))) +(0.00000812*(Math.pow(B2, 2))) -(0.0007982*C2) +(0.0419669*((D2==47?1:0))) +(1.041139*(Math.pow(((D2==52?(6/7):(D2==53?3/7:0))), 2))) -(0.1213413*D2) +(0.0129541*(Math.pow(D2, 2))) -(0.0003998*(Math.pow(D2, 3))) +(0.00000373*(Math.pow(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*(Math.log(G2))) +(1.802581*F2*(Math.log(G2))) +(1.217256*(Math.log(L2))) -(0.5184693*F2*(Math.log(L2+1))) -(0.1466195*M2) -(0.157074*N2) +(0.0150286*(Math.log(O2+1))) -1.9122703 ) ) ) ) // console.log(ProbSellout) // ## column Q var ZIfSellout = ((-0.0016507*A2) +(0.0052863*B2) +(0.0000186*(Math.pow(A2, 2))) -(0.0000205*(Math.pow(B2, 2))) +(0.0015585*C2) +(0.2960315*E2) -(0.5571162*F2) -(0.0105103*F2*G2) +(0.0739237*H2) -(0.100593*I2) +(0.0156484*G2) +(0.1381832*K2) +(0.3338621*F2*(Math.log(G2))) +(0.1955426*F2*(Math.log(L2+1))) +(0.0734202*M2) -(0.1991816*N2)-2.682552) // console.log(ZIfSellout) var ZIfNoSellout = ( (0.0011112*B2) +(0.0000139*(Math.pow(A2, 2))) -(0.0007004*A2) -(0.000000678*(Math.pow(B2, 2))) +(0.2004303*E2) -(1.477247*F2) -(0.006352*F2*G2) +(0.38273282*H2) +(0.0155657*G2) +(0.1257408*F2*K2) +(0.5647975*F2*(Math.log(G2))) +(0.1675119*(Math.log(L2+1))) +(0.1041002*M2) +(0.0932572*N2) -1.186324) var projZ =(ProbSellout*ZIfSellout)+((1-ProbSellout)*ZIfNoSellout) // console.log(projZ) var WeekAvRatio = ( (0.1219971*((D2==47?1:0))) +(0.3760431*(Math.pow(((D2==52?(6/7):(D2==53?3/7:0))), 2))) -(0.0392583*D2) +(0.0030492*(Math.pow(D2, 2))) -(0.0000761*(Math.pow(D2, 3))) +(0.000000606*(Math.pow(D2, 4))) +1.052012 ) // console.log(WeekAvRatio) var WeekStdevRatio = ( (0.040333*((D2==47?1:0))) +(0.4126905*(((D2==52?(6/7):(D2==53?3/7:0))))) -(0.5734843*(Math.pow(((D2==52?(6/7):(D2==53?3/7:0))), 2))) +(0.0358187*D2) -(0.0022887*(Math.pow(D2, 2))) +(0.0000488*(Math.pow(D2, 3))) -(0.000000324*(Math.pow(D2, 4))) +0.8853995 ) console.log("projZ " + projZ + ", " + "WeekStdevRatio " + WeekStdevRatio + ", " + "weeklystde_2015_16 " + weeklystde_2015_16 + ", " + "WeekAvRatio " + WeekAvRatio + ", " + "weekly_av_2015_16 " + weekly_av_2015_16 + ", " ) var ProjGross =(projZ*WeekStdevRatio*weeklystde_2015_16)+(WeekAvRatio*weekly_av_2015_16) var finalNum = ProjGross.toFixed(); console.log(finalNum) var Revenue = d3.select("#result").append("text") .text(finalNum + "$ USD").style("font-size", 30) } // end of predictor function </script> </body>
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js