Sha256: 42d6b1d29808d7b4fae27fc978c2a2aab83da907947ed10025dcdfc797849efc

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

<html>
  <head>
    <title>Monotone curve</title>
    <script type="text/javascript" src="../../protovis-d3.3.js"></script>
  </head>
  <body>
    <script type="text/javascript+protovis">

var data = [4.0, 3.9, 3.0, 2.5, 1.0, 1.0, 1.0, 0.7, 0.2, 0.1],
    w = 600,
    h = 400,
    x = pv.Scale.linear(0, data.length+1).range(0, w),
    y = pv.Scale.linear(0, 4.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(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.Line)
    .data(data)
    .left(function() x(this.index+1))
    .bottom(y)
    .interpolate("monotone");

vis.add(pv.Dot)
    .data(data)
    .left(function() x(this.index+1))
    .bottom(y)
    .strokeStyle("#f33");

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-monotone.html