[ Launch: transition paths ] 5109051 by tmcw
-
-
Save tmcw/5109051 to your computer and use it in GitHub Desktop.
transition paths
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {"description":"transition paths","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"index.html":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal"> | |
| <head> | |
| <title>Topic Tag by Hour</title> | |
| <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/> | |
| <!--[if lte IE 6]> | |
| <link rel="stylesheet" href="${request.static_url('app:static/ie6.css')}" type="text/css" media="screen" charset="utf-8" /> | |
| <![endif]--> | |
| </head> | |
| <style type="text/css"> | |
| body { | |
| font: 10px sans-serif; | |
| margin:auto; | |
| text-rendering: optimizeLegibility; | |
| } | |
| body, #chart {width:1024px;} | |
| svg { | |
| border: 1px solid #DEDEDE; | |
| width:100%; | |
| } | |
| .axis path, | |
| .axis line { | |
| fill: none; | |
| stroke: #000; | |
| shape-rendering: crispEdges; | |
| } | |
| .x.axis path { | |
| fill: none; | |
| shape-rendering: crispEdges; | |
| } | |
| .line { | |
| fill: none; | |
| stroke-width: 5px; | |
| opacity: .6 | |
| } | |
| .dot {opacity: .7;} | |
| .dot:hover {color:'#000000'; opacity: 1;} | |
| .label {color:'#abc123';} | |
| .overlay { | |
| fill: none; | |
| pointer-events: all; | |
| cursor: ew-resize; | |
| } | |
| .tag.label { | |
| font: 500 70px "Helvetica Neue"; | |
| fill: #ddd; | |
| } | |
| .tag.label.active { | |
| fill: #aaa; | |
| } | |
| h1,h2 {letter-spacing: 1px;font-family: "Helvetica Neue", Helvetica, sans-serif; line-height: 36px; } | |
| h1 {float:left;display:inline-block;text-shadow: 2px 2px 2px #CCCCCC; opacity: .9;} | |
| h2 {display:inline-block;float:right;} | |
| emboss { | |
| color: #ECECF6; | |
| text-shadow: -1px -1px 1px #FFFFFF, 1px 1px 1px #000000; | |
| } | |
| div {clear:both;} | |
| </style> | |
| <body> | |
| <div><h1 class="emboss">Tag By Hour</h1> | |
| <h2>${tag}</h2> | |
| </div> | |
| <div id="chart"></div> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var mydata = {"Academy.Awards": [0, 11, 0, 0, 0, 0, 21, 9, 18, 9, 53, 46, 22, 34, 15, 15, 28, 16, 21, 10, 39, 52, 4, 14]}; | |
| var data = mydata[Object.keys(mydata)]; | |
| console.log(data); | |
| var margin = {top: 50, right: 30, bottom: 30, left: 90}, | |
| width = 1000 - margin.left - margin.right, | |
| height = 500 - margin.top - margin.bottom; | |
| var colorScale = d3.scale.category20(); | |
| var parseDate = d3.time.format("%d-%b-%y").parse; | |
| var x = d3.scale.linear() | |
| .range([0, width]); | |
| var y = d3.scale.linear() | |
| .range([height, 0]); | |
| var xAxis = d3.svg.axis() | |
| .scale(x) | |
| .tickSize(2) | |
| .tickPadding(10) | |
| .ticks(data.length-1) | |
| .orient("bottom"); | |
| var yAxis = d3.svg.axis() | |
| .scale(y) | |
| .orient("left"); | |
| x.domain([0,data.length-1]); | |
| y.domain([0,d3.max(data,function(d){return d;})]); | |
| var line = d3.svg.line() | |
| .x(function(d,i) {return x(i); }) | |
| .y(function(d) { return y(d); }); | |
| var svg = d3.select("#chart").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 + ")"); | |
| svg.append("g") | |
| .attr("class", "x axis") | |
| .attr("transform", "translate(0," + height + ")") | |
| .call(xAxis); | |
| svg.append("text") | |
| .attr("class", "x label") | |
| .attr("text-anchor", "end") | |
| .attr("x", width) | |
| .attr("y", height + 30) | |
| .text("hours of the day") | |
| .style('color','#DDD'); | |
| svg.append("g") | |
| .attr("class", "y axis") | |
| .call(yAxis) | |
| svg.append("text") | |
| .attr("class", "y label") | |
| .attr("text-anchor", "end") | |
| .attr("y", 6) | |
| .attr("dy", ".75em") | |
| .attr("transform", "rotate(-90)") | |
| .text("tagged questions") | |
| .style('color','#DDD'); | |
| svg.append("text") | |
| .attr("class", "tag label") | |
| .attr("text-anchor", "end") | |
| .attr("y",height - 30) | |
| .attr("x", width) | |
| .text(tag); | |
| svg.selectAll(".dot") | |
| .data(data) | |
| .enter().append("circle") | |
| .attr({ | |
| "class": "dot", | |
| "r" : 5, | |
| "fill": "#2ca02c", | |
| "stroke-width":"1px", | |
| "cx" : function(d,i) { | |
| return x(i); | |
| }, | |
| "cy": function(d) { | |
| return y(d); | |
| }, | |
| "stroke": function(d,i){ | |
| return colorScale(i); | |
| } | |
| }); | |
| svg.append("path") | |
| .datum(data) | |
| .attr("class", "line") | |
| .transition().duration(2000) | |
| .attr("d", line) | |
| .style("fill","none") | |
| .style("stroke",function(d,i){return colorScale(i);}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment