| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <html>
- <head>
- <title>Scatterplot</title>
- <script type="text/javascript" src="../protovis-d3.1.js"></script>
- </head>
- <body>
- <script type="text/javascript+protovis">
- var data = pv.range(100).map(Math.random),
- w = 400,
- h = 400,
- x = pv.Scale.linear(0, 99).range(0, w),
- y = pv.Scale.linear(0, 1).range(0, h),
- c = pv.Scale.linear(0, 1).range("orange", "brown");
- var vis = new pv.Panel()
- .width(w)
- .height(h)
- .bottom(20)
- .left(20)
- .right(10)
- .top(5)
- .strokeStyle("#ccc");
- vis.add(pv.Rule)
- .data(y.ticks())
- .bottom(function(d) Math.round(y(d)) - .5)
- .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(function(d) Math.round(x(d)) - .5)
- .strokeStyle("#eee")
- .anchor("bottom").add(pv.Label)
- .text(function(d) d.toFixed());
- vis.add(pv.Dot)
- .data(data)
- .left(function() x(this.index))
- .bottom(y)
- .strokeStyle(c)
- .fillStyle(function() this.strokeStyle().alpha(.2));
- vis.render();
- </script>
- </body>
- </html>
|