| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <html>
- <head>
- <title>Column Chart</title>
- <script type="text/javascript" src="../protovis-d3.1.js"></script>
- </head>
- <body>
- <script type="text/javascript+protovis">
- var data = pv.range(10).map(Math.random),
- w = 250,
- h = 400,
- x = pv.Scale.ordinal(pv.range(10)).splitBanded(0, w, 4/5),
- y = pv.Scale.linear(0, 1).range(0, h);
- var vis = new pv.Panel()
- .width(w)
- .height(h)
- .bottom(20)
- .left(20)
- .right(5)
- .top(5);
- var bar = vis.add(pv.Bar)
- .data(data)
- .left(function() x(this.index))
- .width(x.range().band)
- .bottom(0)
- .height(y);
- bar.anchor("top").add(pv.Label)
- .textStyle("white")
- .text(function(d) d.toFixed(1));
- bar.anchor("bottom").add(pv.Label)
- .textMargin(5)
- .textBaseline("top")
- .text(function() "ABCDEFGHIJK".charAt(this.index));
- vis.add(pv.Rule)
- .data(y.ticks())
- .bottom(function(d) Math.round(y(d)) - .5)
- .strokeStyle(function(d) d ? "rgba(255,255,255,.3)" : "#000")
- .add(pv.Rule)
- .left(0)
- .width(5)
- .strokeStyle("#000")
- .anchor("left").add(pv.Label)
- .text(function(d) d.toFixed(1));
- vis.render();
- </script>
- </body>
- </html>
|