D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
dukevis
Full window
Github gist
mental disabilities streamgraph
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <link href="nv.d3.css" rel="stylesheet" type="text/css"> <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.2/d3.min.js" charset="utf-8"></script> <script src="nv.d3.js"></script> <style> text { font: 12px sans-serif; } svg { display: block; } html, body, svg { margin: 0px; padding: 0px; height: 100%; width: 100%; } </style> </head> <!--body class='with-3d-shadow with-transitions'--> <body> <svg id="chart1"></svg> <script> var disability_data = "category,date,val\nintellectual disability,1945,0\nintellectual disability,1946,0\nintellectual disability,1947,0\nintellectual disability,1948,0\nintellectual disability,1949,0\nintellectual disability,1950,0\nintellectual disability,1951,0\nintellectual disability,1952,0\nintellectual disability,1953,0.001046025\nintellectual disability,1954,0.00203666\nintellectual disability,1955,0\nintellectual disability,1956,0\nintellectual disability,1957,0\nintellectual disability,1958,0.000919118\nintellectual disability,1959,0\nintellectual disability,1960,0.000777605\nintellectual disability,1961,0.000773994\nintellectual disability,1962,0.000731529\nintellectual disability,1963,0\nintellectual disability,1964,0.000923361\nintellectual disability,1965,0.00177305\nintellectual disability,1966,0.001253656\nintellectual disability,1967,0.000379939\nintellectual disability,1968,0.000680041\nintellectual disability,1969,0\nintellectual disability,1970,0\nintellectual disability,1971,0.000301023\nintellectual disability,1972,0.001182732\nintellectual disability,1973,0.001145803\nintellectual disability,1974,0.000279096\nintellectual disability,1975,0.001942825\nintellectual disability,1976,0\nintellectual disability,1977,0.000513215\nintellectual disability,1978,0.000490436\nintellectual disability,1979,0.000225175\nintellectual disability,1980,0.000218723\nintellectual disability,1981,0.000392465\nintellectual disability,1982,0.000552995\nintellectual disability,1983,0.000348614\nintellectual disability,1984,0.000494153\nintellectual disability,1985,0.000152602\nintellectual disability,1986,0.000688137\nintellectual disability,1987,0.000812568\nintellectual disability,1988,0.000497018\nintellectual disability,1989,0.000352651\nintellectual disability,1990,0.000457247\nintellectual disability,1991,0.000345026\nintellectual disability,1992,0.001333926\nintellectual disability,1993,0.001425126\nintellectual disability,1994,0.001525475\nintellectual disability,1995,0.001123137\nintellectual disability,1996,0.001970721\nintellectual disability,1997,0.003602812\nintellectual disability,1998,0.004842615\nintellectual disability,1999,0.004573295\nintellectual disability,2000,0.003755077\nintellectual disability,2001,0.005011257\nintellectual disability,2002,0.005018562\nintellectual disability,2003,0.00597597\nintellectual disability,2004,0.006305316\nintellectual disability,2005,0.006825939\nintellectual disability,2006,0.008569151\nintellectual disability,2007,0.009328535\nintellectual disability,2008,0.011051454\nintellectual disability,2009,0.012109596\nintellectual disability,2010,0.012289807\nintellectual disability,2011,0.014523981\nintellectual disability,2012,0.016319198\nintellectual disability,2013,0.017840602\nintellectual disability,2014,0.014205768\nlearning disability,1945,0.017857143\nlearning disability,1946,0\nlearning disability,1947,0.004975124\nlearning disability,1948,0\nlearning disability,1949,0\nlearning disability,1950,0\nlearning disability,1951,0.001179245\nlearning disability,1952,0\nlearning disability,1953,0.001046025\nlearning disability,1954,0\nlearning disability,1955,0\nlearning disability,1956,0\nlearning disability,1957,0\nlearning disability,1958,0\nlearning disability,1959,0.001631321\nlearning disability,1960,0\nlearning disability,1961,0\nlearning disability,1962,0\nlearning disability,1963,0.001087548\nlearning disability,1964,0.007848569\nlearning disability,1965,0.005319149\nlearning disability,1966,0.004178855\nlearning disability,1967,0.007978723\nlearning disability,1968,0.010880653\nlearning disability,1969,0.010271703\nlearning disability,1970,0.008441558\nlearning disability,1971,0.009632751\nlearning disability,1972,0.012123004\nlearning disability,1973,0.017187052\nlearning disability,1974,0.012001116\nlearning disability,1975,0.013322231\nlearning disability,1976,0.018928286\nlearning disability,1977,0.011803952\nlearning disability,1978,0.022069642\nlearning disability,1979,0.02049088\nlearning disability,1980,0.026465442\nlearning disability,1981,0.024136578\nlearning disability,1982,0.023778802\nlearning disability,1983,0.025100227\nlearning disability,1984,0.022401581\nlearning disability,1985,0.016023195\nlearning disability,1986,0.017065786\nlearning disability,1987,0.01719935\nlearning disability,1988,0.015159046\nlearning disability,1989,0.016339485\nlearning disability,1990,0.015546411\nlearning disability,1991,0.013341001\nlearning disability,1992,0.014117386\nlearning disability,1993,0.015895637\nlearning disability,1994,0.015051358\nlearning disability,1995,0.017663876\nlearning disability,1996,0.016516517\nlearning disability,1997,0.014586995\nlearning disability,1998,0.013663092\nlearning disability,1999,0.011514904\nlearning disability,2000,0.011571768\nlearning disability,2001,0.010894037\nlearning disability,2002,0.009212155\nlearning disability,2003,0.008995408\nlearning disability,2004,0.008850581\nlearning disability,2005,0.008862711\nlearning disability,2006,0.007124352\nlearning disability,2007,0.008050005\nlearning disability,2008,0.006621924\nlearning disability,2009,0.006359716\nlearning disability,2010,0.005605148\nlearning disability,2011,0.006463969\nlearning disability,2012,0.006250702\nlearning disability,2013,0.005477025\nlearning disability,2014,0.005596212\nmental deficiency,1945,0.089285714\nmental deficiency,1946,0.085561497\nmental deficiency,1947,0.064676617\nmental deficiency,1948,0.071770335\nmental deficiency,1949,0.058365759\nmental deficiency,1950,0.033846154\nmental deficiency,1951,0.047169811\nmental deficiency,1952,0.025879917\nmental deficiency,1953,0.040794979\nmental deficiency,1954,0.039714868\nmental deficiency,1955,0.03030303\nmental deficiency,1956,0.031746032\nmental deficiency,1957,0.043518519\nmental deficiency,1958,0.039522059\nmental deficiency,1959,0.031810767\nmental deficiency,1960,0.025660964\nmental deficiency,1961,0.02244582\nmental deficiency,1962,0.016825165\nmental deficiency,1963,0.016313214\nmental deficiency,1964,0.014312096\nmental deficiency,1965,0.015514184\nmental deficiency,1966,0.017551191\nmental deficiency,1967,0.009878419\nmental deficiency,1968,0.010540632\nmental deficiency,1969,0.005632869\nmental deficiency,1970,0.006168831\nmental deficiency,1971,0.004515352\nmental deficiency,1972,0.003548196\nmental deficiency,1973,0.004010312\nmental deficiency,1974,0.004465532\nmental deficiency,1975,0.003330558\nmental deficiency,1976,0.002665956\nmental deficiency,1977,0.003849115\nmental deficiency,1978,0.004659147\nmental deficiency,1979,0.004728665\nmental deficiency,1980,0.003062117\nmental deficiency,1981,0.003924647\nmental deficiency,1982,0.002764977\nmental deficiency,1983,0.001394457\nmental deficiency,1984,0.000988305\nmental deficiency,1985,0.001068213\nmental deficiency,1986,0.001101018\nmental deficiency,1987,0.000947996\nmental deficiency,1988,0.000621272\nmental deficiency,1989,0.000470201\nmental deficiency,1990,0.001143118\nmental deficiency,1991,0.000575043\nmental deficiency,1992,0.000555803\nmental deficiency,1993,0.000548125\nmental deficiency,1994,0.000101698\nmental deficiency,1995,0.00030631\nmental deficiency,1996,0.000750751\nmental deficiency,1997,0.000351494\nmental deficiency,1998,0.000259426\nmental deficiency,1999,0.000244998\nmental deficiency,2000,0.000459805\nmental deficiency,2001,0\nmental deficiency,2002,0.000137495\nmental deficiency,2003,0.000188715\nmental deficiency,2004,0.000173541\nmental deficiency,2005,0.000110096\nmental deficiency,2006,9.96413E-05\nmental deficiency,2007,0.000142059\nmental deficiency,2008,0.000134228\nmental deficiency,2009,4.35597E-05\nmental deficiency,2010,0.000124559\nmental deficiency,2011,3.9901E-05\nmental deficiency,2012,7.48587E-05\nmental deficiency,2013,0.000201361\nmental deficiency,2014,0\nmental handicap,1945,0\nmental handicap,1946,0\nmental handicap,1947,0\nmental handicap,1948,0\nmental handicap,1949,0.003891051\nmental handicap,1950,0.006153846\nmental handicap,1951,0.001179245\nmental handicap,1952,0.004140787\nmental handicap,1953,0.005230126\nmental handicap,1954,0.012219959\nmental handicap,1955,0.002164502\nmental handicap,1956,0.00297619\nmental handicap,1957,0.000925926\nmental handicap,1958,0.003676471\nmental handicap,1959,0.004078303\nmental handicap,1960,0.00155521\nmental handicap,1961,0.004643963\nmental handicap,1962,0\nmental handicap,1963,0.001087548\nmental handicap,1964,0.004155125\nmental handicap,1965,0.002659574\nmental handicap,1966,0.002089427\nmental handicap,1967,0.005319149\nmental handicap,1968,0.003740224\nmental handicap,1969,0.005964215\nmental handicap,1970,0.005844156\nmental handicap,1971,0.008729681\nmental handicap,1972,0.007687759\nmental handicap,1973,0.00973933\nmental handicap,1974,0.008931063\nmental handicap,1975,0.012212046\nmental handicap,1976,0.011197014\nmental handicap,1977,0.010520914\nmental handicap,1978,0.017165277\nmental handicap,1979,0.010132853\nmental handicap,1980,0.010498688\nmental handicap,1981,0.013147567\nmental handicap,1982,0.011428571\nmental handicap,1983,0.009761199\nmental handicap,1984,0.011200791\nmental handicap,1985,0.008393102\nmental handicap,1986,0.009909166\nmental handicap,1987,0.012053088\nmental handicap,1988,0.010810139\nmental handicap,1989,0.010697073\nmental handicap,1990,0.009487883\nmental handicap,1991,0.009430707\nmental handicap,1992,0.004668742\nmental handicap,1993,0.004165753\nmental handicap,1994,0.003254348\nmental handicap,1995,0.002246273\nmental handicap,1996,0.001876877\nmental handicap,1997,0.001230228\nmental handicap,1998,0.000432376\nmental handicap,1999,0.000979992\nmental handicap,2000,0.00053644\nmental handicap,2001,7.26269E-05\nmental handicap,2002,0.000412485\nmental handicap,2003,0.000314525\nmental handicap,2004,0.000289235\nmental handicap,2005,0\nmental handicap,2006,9.96413E-05\nmental handicap,2007,4.7353E-05\nmental handicap,2008,4.47427E-05\nmental handicap,2009,0.000174239\nmental handicap,2010,0.000166078\nmental handicap,2011,3.9901E-05\nmental handicap,2012,3.74294E-05\nmental handicap,2013,0\nmental handicap,2014,0\nmental retardation,1945,0\nmental retardation,1946,0.010695187\nmental retardation,1947,0.004975124\nmental retardation,1948,0.014354067\nmental retardation,1949,0.019455253\nmental retardation,1950,0.012307692\nmental retardation,1951,0.018867925\nmental retardation,1952,0.025879917\nmental retardation,1953,0.018828452\nmental retardation,1954,0.041751527\nmental retardation,1955,0.023809524\nmental retardation,1956,0.026785714\nmental retardation,1957,0.02962963\nmental retardation,1958,0.052389706\nmental retardation,1959,0.057911909\nmental retardation,1960,0.043545879\nmental retardation,1961,0.054179567\nmental retardation,1962,0.065106072\nmental retardation,1963,0.065252855\nmental retardation,1964,0.0710988\nmental retardation,1965,0.08643617\nmental retardation,1966,0.073965733\nmental retardation,1967,0.079407295\nmental retardation,1968,0.093845631\nmental retardation,1969,0.082836315\nmental retardation,1970,0.07012987\nmental retardation,1971,0.072847682\nmental retardation,1972,0.052631579\nmental retardation,1973,0.055571469\nmental retardation,1974,0.054144572\nmental retardation,1975,0.048293089\nmental retardation,1976,0.045587843\nmental retardation,1977,0.047729022\nmental retardation,1978,0.046346248\nmental retardation,1979,0.045485251\nmental retardation,1980,0.05096238\nmental retardation,1981,0.053178964\nmental retardation,1982,0.050138249\nmental retardation,1983,0.040787868\nmental retardation,1984,0.036896722\nmental retardation,1985,0.037082252\nmental retardation,1986,0.037434627\nmental retardation,1987,0.036023835\nmental retardation,1988,0.026714712\nmental retardation,1989,0.025743505\nmental retardation,1990,0.026748971\nmental retardation,1991,0.028982174\nmental retardation,1992,0.026789684\nmental retardation,1993,0.026638895\nmental retardation,1994,0.020339673\nmental retardation,1995,0.020114356\nmental retardation,1996,0.020364114\nmental retardation,1997,0.019156415\nmental retardation,1998,0.017381529\nmental retardation,1999,0.017313189\nmental retardation,2000,0.016936164\nmental retardation,2001,0.012491829\nmental retardation,2002,0.01306201\nmental retardation,2003,0.011008366\nmental retardation,2004,0.010354602\nmental retardation,2005,0.008532423\nmental retardation,2006,0.008818254\nmental retardation,2007,0.007907946\nmental retardation,2008,0.006442953\nmental retardation,2009,0.006533955\nmental retardation,2010,0.005812747\nmental retardation,2011,0.004907829\nmental retardation,2012,0.002956919\nmental retardation,2013,0.002013612\nmental retardation,2014,0.002582867\nother mental term,1945,0.017857143\nother mental term,1946,0.021390374\nother mental term,1947,0.009950249\nother mental term,1948,0.004784689\nother mental term,1949,0.011673152\nother mental term,1950,0.006153846\nother mental term,1951,0.004716981\nother mental term,1952,0.007246377\nother mental term,1953,0.003138075\nother mental term,1954,0.010183299\nother mental term,1955,0.00974026\nother mental term,1956,0.008928571\nother mental term,1957,0.007407407\nother mental term,1958,0.010110294\nother mental term,1959,0.01141925\nother mental term,1960,0.010108865\nother mental term,1961,0.01625387\nother mental term,1962,0.010972933\nother mental term,1963,0.008700381\nother mental term,1964,0.003693444\nother mental term,1965,0.007535461\nother mental term,1966,0.00459674\nother mental term,1967,0.003799392\nother mental term,1968,0.005100306\nother mental term,1969,0.002319417\nother mental term,1970,0.003246753\nother mental term,1971,0.001806141\nother mental term,1972,0.001774098\nother mental term,1973,0.002578058\nother mental term,1974,0.00195367\nother mental term,1975,0.001942825\nother mental term,1976,0.001866169\nother mental term,1977,0.003335899\nother mental term,1978,0.001961746\nother mental term,1979,0.001801396\nother mental term,1980,0.003499563\nother mental term,1981,0.002158556\nother mental term,1982,0.002396313\nother mental term,1983,0.001568764\nother mental term,1984,0.001647175\nother mental term,1985,0.002289028\nother mental term,1986,0.001238646\nother mental term,1987,0.001625135\nother mental term,1988,0.000994036\nother mental term,1989,0.001528153\nother mental term,1990,0.001028807\nother mental term,1991,0.000345026\nother mental term,1992,0.000889284\nother mental term,1993,0.000986626\nother mental term,1994,0.000915285\nother mental term,1995,0.000714723\nother mental term,1996,0.001407658\nother mental term,1997,0.000790861\nother mental term,1998,0.000951228\nother mental term,1999,0.000571662\nother mental term,2000,0.001226148\nother mental term,2001,0.000798896\nother mental term,2002,0.000412485\nother mental term,2003,0.000880669\nother mental term,2004,0.000867704\nother mental term,2005,0.000660575\nother mental term,2006,0.000597848\nother mental term,2007,0.000757648\nother mental term,2008,0.000715884\nother mental term,2009,0.000871194\nother mental term,2010,0.000456716\nother mental term,2011,0.000837922\nother mental term,2012,0.000636299\nother mental term,2013,0.000563811\nother mental term,2014,0.000430478" var new_string_data = d3.csv.parse(disability_data) console.log(new_string_data) var exampleData = [ ]; // populate the empty object with your data new_string_data.forEach(function (d){ //new_string_data.forEach(function (d){ d.date = +d.date d.val = +d.val var pushed = false; var cat; for (cat in exampleData) { if(exampleData[cat].key == d.category) { //console.log(exampleData) exampleData[cat].values.push([d.date, d.val]) pushed = true; } } if(!pushed) { exampleData.push({key: d.category, values: [[d.date, d.val]]}) } //console.log(d.category) }) console.log(exampleData) var colors = ["#BE6528", "#D39163", "#054C38", "#1D6D54", "#468E76", "#84BFA9"]; var chart; nv.addGraph(function() { chart = nv.models.stackedAreaChart() .useInteractiveGuideline(true) .x(function(d) { console.log(d[0]); return d[0] }) .y(function(d) { console.log(d[1]); return d[1] }) //.controlLabels({stacked: "Stacked"}) .color(colors) .showControls(false) .style('stream-center') //.style('stream') .duration(300); //chart.xAxis.tickFormat(function(d) { return d3.time.format('%x')(new Date(d)) }); //chart.xAxis.tickFormat(d3.format(',.2f')); chart.yAxis.tickFormat(d3.format('.01%')); chart.legend.vers('furious') .expanded(false); d3.select('#chart1') .datum(exampleData) .transition().duration(1000) .call(chart) .each('start', function() { setTimeout(function() { d3.selectAll('#chart1 *').each(function() { if(this.__transition__) this.__transition__.duration = 1; }) }, 0) }); nv.utils.windowResize(chart.update); return chart; }); //}); </script> </body> </html>
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.2/d3.min.js