Sha256: 9b5b7613b99fff732b26edf54395cb8c35d55d0101eab013be26ee11ef680e40
Contents?: true
Size: 1.8 KB
Versions: 1
Compression:
Stored size: 1.8 KB
Contents
<html> <head> <title>Cardinal Splines</title> <script type="text/javascript" src="../../protovis-d3.3.js"></script> </head> <body> <script type="text/javascript+protovis"> var data = pv.range(10).map(function(x) { return {x: x, y: Math.sin(x * Math.PI + Math.PI / 2)}; }), w = 800, h = 400, x = pv.Scale.linear(data, function(d) d.x).range(0, w), y = pv.Scale.linear(-1.5, 1.5).range(0, h); var vis = new pv.Panel() .width(w) .height(h) .strokeStyle("#ccc") .margin(20); vis.add(pv.Rule) .data(y.ticks()) .visible(function() !(this.index % 2)) .bottom(y) .strokeStyle("#eee") .anchor("left").add(pv.Label) .text(function(d) d.toFixed(1)); vis.add(pv.Rule) .data(x.ticks()) .visible(function(d) d > 0) .left(x) .strokeStyle("#eee") .anchor("bottom").add(pv.Label) .text(function(d) d.toFixed()); vis.add(pv.Line) .data(data) .left(function(d) x(d.x)) .bottom(function(d) y(d.y)) .interpolate("cardinal"); vis.add(pv.Panel) .data(data) .add(pv.Dot) .strokeStyle("#1f77b4") .left(function(d) x(d.x)) .bottom(function(d) y(d.y)) .add(pv.Line) .data(function(d) { var dm = data[this.parent.index - 1], dp = data[this.parent.index + 1]; if (!dm) { dm = d; dp = data[this.parent.index + 2]; } else if (!dp) { dp = d; dm = data[this.parent.index - 2]; } var dx = (dp.x - dm.x) / 4, dy = (dp.y - dm.y) / 4; return [ {x: d.x - dx, y: d.y - dy}, {x: d.x + dx, y: d.y + dy} ]; }) .fillStyle(null) .strokeStyle(pv.colors("orange", "brown").by(function() this.parent.index >> 1 & 1)) .add(pv.Dot); vis.render(); </script> </body> </html>
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubyvis-0.1.1 | vendor/tests/mark/line-cardinal.html |