Wednesday, May 25, 2011

pv.Scale.Linear (Excel Simulated Data)

To make myself understand how actually pv.Scale.linear does, I'd done some simulation in Excel spreadsheet. May it can help you as well...

First, I simulate using domain 0 to 200 and data range from 0,10. The simulated f(x) will look like pic below

pv.Scale.linear simulation for domain = [0,200] and range = [0,10]
pv.Scale.linear syntax related to domain and data range is :

pv.Scale.linear(d0, d1).range(r0, r1);

And this code show how the pv.Scale.linear construct do...


<html>
    <head>
    <script type="text/javascript"  src="protovis-r3.2.js"></script>
    <title>PV Scale Linear</title>
    </head>
    <body>
    <div id="pesan">
    </div>
    <script type="text/javascript+protovis"
        var y = pv.Scale.linear(0200).range(010);
        document.getElementById("pesan").innerHTML += "y.ticks() = " + y.ticks() + "<BR />";
        for(i=0;i<=17;i++)
            document.getElementById("pesan").innerHTML += "y(" + i + ") = " + y(i).toFixed(2) + "<BR />";
    </script>
    </body>
</html>


Result :

y.ticks() = 0,20,40,60,80,100,120,140,160,180,200
y(0) = 0.00
y(1) = 0.05
y(2) = 0.10
y(3) = 0.15
y(4) = 0.20
y(5) = 0.25
y(6) = 0.30
y(7) = 0.35
y(8) = 0.40
y(9) = 0.45
y(10) = 0.50
y(11) = 0.55
y(12) = 0.60
y(13) = 0.65
y(14) = 0.70
y(15) = 0.75
y(16) = 0.80
y(17) = 0.85



For practical conclusion, domain is the divider whereas range is the data itself.

Hope this helps ....

No comments:

Post a Comment