Skip to content

Instantly share code, notes, and snippets.

@vargasmontero
Last active August 29, 2015 14:26
Show Gist options
  • Save vargasmontero/ded1f8645bfae584dfe9 to your computer and use it in GitHub Desktop.
Save vargasmontero/ded1f8645bfae584dfe9 to your computer and use it in GitHub Desktop.
test
{"description":"test","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.tsc":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.tsv":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data2.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"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,"tab":"edit","display_percent":0.7,"thumbnail":"http://i.imgur.com/Z4ghHZY.png","fullscreen":false,"ajax-caching":true}
{ "points":[
{"date":"19-Oct-11","value":"398.62"},
{"date":"18-Oct-11","value":"422.24"},
{"date":"17-Oct-11","value":"419.99"},
{"date":"14-Oct-11","value":"422.00"},
{"date":"13-Oct-11","value":"408.43"},
{"date":"12-Oct-11","value":"402.19"},
{"date":"11-Oct-11","value":"400.29"},
{"date":"10-Oct-11","value":"388.81"},
{"date":"7-Oct-11","value":"369.80"},
{"date":"6-Oct-11","value":"377.37"},
{"date":"5-Oct-11","value":"378.25"},
{"date":"4-Oct-11","value":"372.50"},
{"date":"3-Oct-11","value":"374.60"}
]}
var margin = {top: 20, right: 20, bottom: 30, left: 50},
margin2 = {top: 430, right: 10, bottom: 20, left: 40},
width = 750 - margin.left - margin.right,
height2 = 500 - margin2.top - margin2.bottom,
height = 500 - margin.top - margin.bottom;
var parseDate = d3.time.format("%d-%b-%y").parse;
var x = d3.time.scale()
.range([0, width]);
var y = d3.scale.linear()
.range([height, 0]);
var x2 = d3.time.scale().range([0, width]),
y2 = d3.scale.linear().range([height2, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(y)
.orient("left");
var line = d3.svg.line()
.x(function(d) { return x(d.date); })
.y(function(d) { return y(d.value); });
var svg = d3.select("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var data = tributary.data2.points
data.forEach(function(d) {
d.date = parseDate(d.date);
d.value = +parseFloat(d.value);
});
x.domain(d3.extent(data, function(d) { return d.date; }));
y.domain(d3.extent(data, function(d) { return d.value; }));
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Price ($)");
svg.append("path")
.datum(data)
.attr("class", "line")
.attr("d", line);
/*d3.json(tributary.data2.points , function(error, data) {
if (error) throw error;
data.forEach(function(d) {
d.date = parseDate(d.date);
d.close = +d.close;
});
x.domain(d3.extent(data, function(d) { return d.date; }));
y.domain(d3.extent(data, function(d) { return d.close; }));
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Price ($)");
svg.append("path")
.datum(data)
.attr("class", "line")
.attr("d", line);
});*/
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.x.axis path {
display: none;
}
.line {
fill: none;
stroke: steelblue;
stroke-width: 1.5px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment