Skip to content

Instantly share code, notes, and snippets.

@ptvans
Forked from anonymous/_.md
Created September 30, 2012 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ptvans/3805708 to your computer and use it in GitHub Desktop.
Save ptvans/3805708 to your computer and use it in GitHub Desktop.
just another inlet to tributary
{"editor_editor":{"coffee":false,"vim":false,"emacs":false,"width":601,"height":546,"hide":false},"endpoint":"tributary","public":true}
//these are your variables - click and drag to change
var time = 310;
var base = 201969;
var conv = 0.016;
var invite = 7.5;
var cycle = 67;
var k = conv * invite;
var di = 0.15;
var data = d3.range(0, time);
//we want to map our x values to pixel values
var xscale = d3.scale.linear()
.domain([d3.min(data), d3.max(data)]) //scale range of chart
.range([0, 555]); //width of chart
//we want to map our y values to pixel values
var yscale = d3.scale.linear()
.domain([base,247887]) //scale range of chart
.range([379, 0]) //height of chart
var line = d3.svg.line()
.x(function(d) {
//for each x value we map it to the pixel value
return xscale(d);
})
.y(function(d,i) {
//this is the math for NEW USERS = base * (k^(t/cycle +1) -1) / (k-1)
var pow = Math.pow(k, d/cycle + 1);//this returns k to the power of d/cycle +1
console.log(base * (pow - 1) / (k - 1))
return yscale(base * (pow - 1) / (k - 1));
});
var svg = d3.select("svg");
var path = svg.append("path")
.data([data])
.attr("d", line) //this calls the line function with this element's data
.style("fill", "none")
.style("stroke", "#4B8FB6")
.style("stroke-width",2)
.attr("transform", "translate(" + [84, 31] + ")")
Display the source blob
Display the rendered blob
Raw
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" class="tributary_svg" width="1278" height="697"><path d="M0,379L1.796116504854369,371.918896909501L3.592233009708738,365.05837187197585L5.3883495145631075,358.41155382837815L7.184466019417476,351.97178575479103L8.980582524271846,345.7326179951839L10.776699029126215,339.68780180185166L12.572815533980583,333.8312830770734L14.368932038834952,328.15719630971955L16.16504854368932,322.6598587007313L17.96116504854369,317.3337644716002L19.75728155339806,312.1735793501324L21.55339805825243,307.1741352279885L23.349514563106798,302.33042498463766L25.145631067961165,297.63759747254966L26.941747572815533,293.0909526585993L28.737864077669904,288.6859369168158L30.533980582524276,284.41813846776563L32.33009708737864,280.2832829599988L34.126213592233015,276.27722918913264L35.92233009708738,272.39596495029224L37.71844660194174,268.635603019742L39.51456310679612,264.9923772616946L41.310679611650485,261.46263885639235L43.10679611650486,258.0428526456846L44.90291262135923,254.72959359244112L46.699029126213595,251.519543350258L48.49514563106796,248.40948694001347L50.29126213592233,245.39630952995344L52.087378640776706,242.47699331607745L53.883495145631066,239.64861449970067L55.67961165048544,236.9083403591653L57.47572815533981,234.25342641277098L59.271844660194176,231.68121367007672L61.06796116504855,229.18912596882979L62.86407766990291,226.77466739484657L64.66019417475728,224.43541978226753L66.45631067961166,222.16904029167637L68.25242718446603,219.97325906366495L70.04854368932038,217.8458769454869L71.84466019417476,215.78476328853088L73.64077669902913,213.78785381439744L75.43689320388349,211.85314854745354L77.23300970873787,209.97870981178409L79.02912621359224,208.16266029054208L80.82524271844662,206.40318114574868L82.62135922330097,204.6985101966622L84.41747572815534,203.04694015489287L86.21359223300972,201.4468169144918L88.00970873786407,199.8965378953055L89.80582524271846,198.39455043793464L91.60194174757282,196.93935024869222L93.39805825242719,195.5294798929979L95.19417475728156,194.16352733570764L96.99029126213593,192.84012452690882L98.7864077669903,191.55794603177034L100.58252427184466,190.31570770307323L102.37864077669903,189.11216539509107L104.17475728155341,187.94611371753393L105.97087378640776,186.81638482830726L107.76699029126213,185.72184726387684L109.56310679611651,184.66140480606782L111.35922330097088,183.6339953841642L113.15533980582525,182.63859001120503L114.95145631067962,181.67419175342016L116.74757281553399,180.73983473176426L118.54368932038835,179.83458315455425L120.33980582524272,178.95753038024304L122.1359223300971,178.10779800938323L123.93203883495146,177.28453500488007L125.72815533980582,176.48691683964861L127.5242718446602,175.71414467081817L129.32038834951456,174.96544453966527L131.11650485436894,174.24006659646534L132.91262135922332,173.537284349492L134.70873786407768,172.85639393740925L136.50485436893206,172.19671342433065L138.3009708737864,171.55758211683488L140.09708737864077,170.938359902259L141.89320388349515,170.33842660760175L143.68932038834953,169.75718137839962L145.48543689320388,169.19404207694885L147.28155339805826,168.6484446992752L149.07766990291265,168.1198428102609L150.87378640776697,167.60770699637482L152.66990291262135,167.11152433544265L154.46601941747574,166.63079788293902L156.2621359223301,166.16504617427805L158.05825242718447,165.71380274261213L159.85436893203885,165.27661565164647L161.65048543689323,164.8530470430102L163.44660194174756,164.44267269772504L165.24271844660194,164.045081611336L167.03883495145632,163.65987558227417L168.83495145631068,163.28666881304446L170.63106796116506,162.92508752383765L172.42718446601944,162.57476957817232L174.2233009708738,162.23536412020704L176.01941747572815,161.90653122334263L177.81553398058253,161.5879415497756L179.6116504854369,161.27927602065233L181.40776699029126,160.9802254965027L183.20388349514565,160.6904904676246L185.00000000000003,160.4097807541153L186.79611650485438,160.1378152152442L188.59223300970874,159.87432146788265L190.38834951456312,159.61903561370156L192.18446601941747,159.3717019748668L193.98058252427185,159.13207283797072L195.77669902912623,158.89990820593772L197.5728155339806,158.67497555765706L199.36893203883494,158.45704961510813L201.16504854368932,158.24591211773293L202.9611650485437,158.04135160384251L204.75728155339806,157.8431631988304L206.55339805825244,157.65114840998174L208.34951456310682,157.46511492767956L210.14563106796118,157.28487643279522L211.94174757281553,157.1102524100862L213.7378640776699,156.941067967403L215.53398058252426,156.77715366052797L217.33009708737865,156.61834532347228L219.12621359223303,156.4644839040554L220.9223300970874,156.3154153046118L222.71844660194176,156.17099022765376L224.51456310679612,156.0310640263469L226.3106796116505,155.89549655963998L228.10679611650485,155.7641520519083L229.90291262135923,155.63689895697115L231.69902912621362,155.5136098263428L233.49514563106797,155.3941611815878L235.29126213592235,155.27843339065322L237.0873786407767,155.16631054805487L238.88349514563106,155.05768035878964L240.67961165048544,154.95243402587195L242.47572815533982,154.8504661413691L244.2718446601942,154.7516745808288L246.06796116504856,154.65596040100067L247.8640776699029,154.56322774074135L249.6601941747573,154.47338372500272L251.45631067961165,154.38633837181894L253.25242718446603,154.30200450218211L255.0485436893204,154.2202976527323L256.84466019417476,154.14113599116266L258.6407766990291,154.0644402342634L260.4368932038835,153.99013356851415L262.2330097087379,153.9181415731553L264.02912621359224,153.84839214565102L265.82524271844665,153.7808154294769L267.621359223301,153.71534374415594L269.41747572815535,153.65191151747433L271.2135922330097,153.590455219808L273.0097087378641,153.53091330049608L274.80582524271847,153.47322612619584L276.6019417475728,153.4173359211564L278.3980582524272,153.3631867093565L280.19417475728153,153.3107242584407L281.99029126213594,153.25989602540412L283.7864077669903,153.21065110397L285.58252427184465,153.16294017360352L287.37864077669906,153.11671545011603L289.1747572815534,153.07193063780855L290.97087378640776,153.02854088310357L292.7669902912622,152.98650272962382L294.56310679611653,152.945774074668L296.3592233009709,152.90631412704437L298.1553398058253,152.86808336621618L299.95145631067965,152.8310435027213L301.74757281553394,152.79515743982324L303.54368932038835,152.7603892363582L305.3398058252427,152.72670407073667L307.13592233009706,152.6940682060722L308.93203883495147,152.66244895638917L310.7281553398058,152.63181465388726L312.5242718446602,152.60213461722674L314.3203883495146,152.57337912079947L316.11650485436894,152.54551936495542L317.91262135922335,152.5185274471619L319.7087378640777,152.49237633405585L321.50485436893206,152.4670398343709L323.30097087378647,152.44249257270417L325.0970873786408,152.4187099641028L326.8932038834951,152.39566818944073L328.68932038834953,152.37334417156475L330.4854368932039,152.35171555217832L332.28155339805824,152.3307606694535L334.07766990291265,152.31045853633125L335.873786407767,152.29078881950622L337.66990291262135,152.27173181905982L339.46601941747576,152.25326844872964L341.2621359223301,152.2353802167966L343.05825242718447,152.21804920756162L344.8543689320389,152.20125806340462L346.65048543689323,152.1849899673999L348.4466019417476,152.1692286264719L350.242718446602,152.15395825507957L352.0388349514563,152.1391635594042L353.83495145631065,152.12482972203367L355.63106796116506,152.1109423871216L357.4271844660194,152.09748764600988L359.2233009708738,152.08445202329776L361.0194174757282,152.07182246334764L362.81553398058253,152.0595863172074L364.61165048543694,152.04773132994256L366.4077669902913,152.03624562836285L368.20388349514565,152.02511770913202L370.00000000000006,152.01433642724334L371.7961165048544,152.0038909848613L373.59223300970876,151.99377092050494L375.3883495145631,151.98396609857076L377.18446601941747,151.97446669918256L378.9805825242718,151.9652632083544L380.77669902912623,151.95634640846475L382.5728155339806,151.9477073690215L384.36893203883494,151.93933743772124L386.16504854368935,151.9312282317805L387.9611650485437,151.92337162954206L389.75728155339806,151.91575976234003L391.55339805825247,151.90838500662022L393.3495145631068,151.90123997630246L395.1456310679612,151.89431751538663L396.9417475728156,151.8876106907818L398.7378640776699,151.88111278536581L400.5339805825243,151.87481729125562L402.33009708737865,151.86871790329147L404.126213592233,151.86280851271925L405.9223300970874,151.85708320107534L407.71844660194176,151.85153623425705L409.5145631067961,151.84616205678012L411.3106796116505,151.84095528621552L413.1067961165049,151.83591070779798L414.90291262135923,151.83102326920306L416.69902912621365,151.8262880754884L418.495145631068,151.82170038418892L420.29126213592235,151.81725560056955L422.08737864077676,151.8129492730219L423.88349514563106,151.80877708860612L425.6796116504854,151.8047348687316L427.4757281553398,151.80081856497185L429.2718446601942,151.79702425500975L431.06796116504853,151.79334813870935L432.86407766990294,151.78978653431042L434.6601941747573,151.78633587473894L436.45631067961165,151.78299270403787L438.25242718446606,151.77975367390238L440.0485436893204,151.77661554032971L441.8446601941748,151.77357516036747L443.6407766990292,151.77062948896764L445.4368932038835,151.76777557593533L447.23300970873794,151.76501056297585L449.02912621359224,151.76233168083098L450.8252427184466,151.75973624650467L452.621359223301,151.7572216605775L454.41747572815535,151.75478540460284L456.2135922330097,151.75242503858368L458.0097087378641,151.75013819853007L459.80582524271847,151.7479225940905L461.6019417475728,151.74577600625867L463.39805825242723,151.74369628515052L465.1941747572816,151.74168134785168L466.99029126213594,151.739729176331L468.78640776699035,151.7378378154198L470.5825242718447,151.73600537085255L472.378640776699,151.73423000737162L474.1747572815534,151.73250994688715L475.97087378640776,151.73084346669748L477.7669902912621,151.72922889776433L479.56310679611653,151.72766462303846L481.3592233009709,151.72614907584492L483.1553398058253,151.7246807383079L484.95145631067965,151.72325813983622L486.747572815534,151.72187985564676L488.5436893203884,151.72054450533898L490.33980582524276,151.71925075151216L492.1359223300971,151.7179972984264L493.9320388349515,151.71678289070363L495.7281553398058,151.71560631207154L497.5242718446602,151.714466384145L499.3203883495146,151.7133619652455L501.11650485436894,151.7122919492588L502.9126213592233,151.71125526452565L504.7087378640777,151.7102508727694L506.50485436893206,151.70927776805675L508.3009708737864,151.70833497578795L510.0970873786408,151.70742155172377L511.8932038834952,151.7065365810373L513.6893203883495,151.70567917739953L515.4854368932039,151.7048484820895L517.2815533980582,151.7040436631369L519.0776699029126,151.703263914487L520.873786407767,151.70250845519385L522.6699029126214,151.70177652863828L524.4660194174758,151.70106740176928L526.2621359223301,151.7003803643721L528.0582524271845,151.6997147283539L529.8543689320389,151.6990698270565L531.6504854368933,151.69844501458894L533.4466019417475,151.69783966517872L535.242718446602,151.6972531725473L537.0388349514564,151.69668494930195L538.8349514563107,151.69613442634588L540.6310679611651,151.69560105231136L542.4271844660194,151.69508429300564L544.2233009708738,151.69458363087585L546.0194174757282,151.6940985644907L547.8155339805826,151.69362860803975L549.6116504854369,151.69317329084427L551.4077669902913,151.69273215688813L553.2038834951456,151.69230476436033L555,151.69189068521192" style="fill: none; stroke: #4b8fb6; stroke-width: 2px; " transform="translate(84,31)"></path></svg>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment