111 lines
13 KiB
HTML
111 lines
13 KiB
HTML
<!DOCTYPE html>
|
|
<meta charset="utf-8">
|
|
|
|
<link href="../src/d3.css" rel="stylesheet" type="text/css">
|
|
|
|
<style>
|
|
|
|
body {
|
|
overflow-y:scroll;
|
|
}
|
|
|
|
text {
|
|
font: 12px sans-serif;
|
|
}
|
|
|
|
#chart1 {
|
|
height: 500px;
|
|
margin: 10px;
|
|
min-width: 100px;
|
|
min-height: 100px;
|
|
/*
|
|
Minimum height and width is a good idea to prevent negative SVG dimensions...
|
|
For example width should be =< margin.left + margin.right + 1,
|
|
of course 1 pixel for the entire chart would not be very useful, BUT should not have errors
|
|
*/
|
|
}
|
|
|
|
</style>
|
|
<body>
|
|
|
|
<div id="chart1">
|
|
</div>
|
|
|
|
<script src="../lib/d3.v2.js"></script>
|
|
<script src="../lib/jquery.min.js"></script>
|
|
<script src="../nv.d3.js"></script>
|
|
<!-- including all the components so I don't have to minify every time I test in development -->
|
|
<script src="../src/nvtooltip.js"></script>
|
|
<script src="../src/models/legend.js"></script>
|
|
<script src="../src/models/axis.js"></script>
|
|
<script src="../src/models/line.js"></script>
|
|
<script src="../src/models/lineWithLegend.js"></script>
|
|
<script src="../src/charts/lineChartDaily.js"></script>
|
|
<script>
|
|
|
|
|
|
|
|
var cumulativeDailyTestData = [
|
|
{
|
|
key: "Actual Return" ,
|
|
values: [ [ 1317614400000 , -1.4475640131507] , [ 1317700800000 , -0.50785241139112] , [ 1317787200000 , 1.2232844878178] , [ 1317873600000 , 2.3277976069464] , [ 1317960000000 , 0.87828538009238] , [ 1318046400000 , 0.87828538009238] , [ 1318132800000 , 0.87828538009238] , [ 1318219200000 , 2.8821394715025] , [ 1318305600000 , 3.0600496997189] , [ 1318392000000 , 4.1615801183747] , [ 1318478400000 , 3.8560316339337] , [ 1318564800000 , 4.2624578565545] , [ 1318651200000 , 4.2624578565545] , [ 1318737600000 , 4.2624578565545] , [ 1318824000000 , 2.8760203477064] , [ 1318910400000 , 4.2802792900813] , [ 1318996800000 , 3.5644216125341] , [ 1319083200000 , 3.8267230522883] , [ 1319169600000 , 4.5897674196334] , [ 1319256000000 , 4.5897674196334] , [ 1319342400000 , 4.5897674196334] , [ 1319428800000 , 6.1435681595838] , [ 1319515200000 , 4.6773634913148] , [ 1319601600000 , 5.5686828861057] , [ 1319688000000 , 8.6510229437140] , [ 1319774400000 , 8.4035095885256] , [ 1319860800000 , 8.4035095885256] , [ 1319947200000 , 8.4035095885256] , [ 1320033600000 , 5.9304228949775] , [ 1320120000000 , 4.6694048881845] , [ 1320206400000 , 5.5755229192740] , [ 1320292800000 , 5.9596062543264] , [ 1320379200000 , 5.8750173069172] , [ 1320465600000 , 5.8750173069172] , [ 1320552000000 , 5.8750173069172] , [ 1320642000000 , 6.2705601567990] , [ 1320728400000 , 6.4422984536501] , [ 1320814800000 , 3.7696655204518] , [ 1320901200000 , 3.9256502879070] , [ 1320987600000 , 4.9896568610477] , [ 1321074000000 , 4.9896568610477] , [ 1321160400000 , 4.9896568610477] , [ 1321246800000 , 4.5101581898062] , [ 1321333200000 , 5.1852026589187] , [ 1321419600000 , 4.1412722333259] , [ 1321506000000 , 2.6646651357988] , [ 1321592400000 , 2.5391402402758] , [ 1321678800000 , 2.5391402402758] , [ 1321765200000 , 2.5391402402758] , [ 1321851600000 , 1.4480191418839] , [ 1321938000000 , 1.1851353770435] , [ 1322024400000 , -0.0110471601546] , [ 1322110800000 , -0.0110471601546] , [ 1322197200000 , -0.2607790366052] , [ 1322283600000 , -0.2607790366052] , [ 1322370000000 , -0.2607790366052] , [ 1322456400000 , -0.2993491727393] , [ 1322542800000 , -0.8721365094791] , [ 1322629200000 , 1.3826624677829] , [ 1322715600000 , 1.1413888639683] , [ 1322802000000 , 1.1916488459919] , [ 1322888400000 , 1.1916488459919] , [ 1322974800000 , 1.1916488459919] , [ 1323061200000 , 1.6640075295100] , [ 1323147600000 , 1.4333447279330] , [ 1323234000000 , 1.5756501095903] , [ 1323320400000 , 0.1566240837346] , [ 1323406800000 , 1.1957087351357] , [ 1323493200000 , 1.1957087351357] , [ 1323579600000 , 1.1957087351357] , [ 1323666000000 , 0.1529279857726] , [ 1323752400000 , -0.4379146622043] , [ 1323838800000 , -1.6307803651431] , [ 1323925200000 , -1.8097182178695] , [ 1324011600000 , -1.6612784009542] , [ 1324098000000 , -1.6612784009542] , [ 1324184400000 , -1.6612784009542] , [ 1324270800000 , -2.7123628804330] , [ 1324357200000 , -0.9156099608796] , [ 1324443600000 , -1.3441101479801] , [ 1324530000000 , -0.4285924644141] , [ 1324616400000 , 0.0289302220607] , [ 1324702800000 , 0.0289302220607] , [ 1324789200000 , 0.0289302220607] , [ 1324875600000 , 0.0289302220607] , [ 1324962000000 , -0.1680182906741] , [ 1325048400000 , -1.1735228321827] , [ 1325134800000 , -0.4819867447246] , [ 1325221200000 , -0.5667569440908] , [ 1325307600000 , -0.5667569440908] , [ 1325394000000 , -0.5667569440908] , [ 1325480400000 , -0.5667569440908] , [ 1325566800000 , 0.6031318427099] , [ 1325653200000 , 0.5247518205078] , [ 1325739600000 , 0.8575949798359] , [ 1325826000000 , 0.9983061584652] , [ 1325912400000 , 0.9983061584652] , [ 1325998800000 , 0.9983061584652] , [ 1326085200000 , 1.4032665222444] , [ 1326171600000 , 1.8976558759597] , [ 1326258000000 , 2.1532858156245] , [ 1326344400000 , 2.3864413393018] , [ 1326430800000 , 1.8718218939651] , [ 1326517200000 , 1.8718218939651] , [ 1326603600000 , 1.8718218939651] , [ 1326690000000 , 1.8718218939651] , [ 1326776400000 , 1.7604328445901] , [ 1326862800000 , 2.6068832572249] , [ 1326949200000 , 3.0615220945767] , [ 1327035600000 , 2.9348684033730] , [ 1327122000000 , 2.9348684033730] , [ 1327208400000 , 2.9348684033730] , [ 1327294800000 , 3.1172684824147] , [ 1327381200000 , 2.9842827363639] , [ 1327467600000 , 3.2794961257832] , [ 1327554000000 , 3.2797701308936] , [ 1327640400000 , 3.7651100285428] , [ 1327726800000 , 3.7651100285428] , [ 1327813200000 , 3.7651100285428] , [ 1327899600000 , 3.4448337693528] , [ 1327986000000 , 3.4404569794837] , [ 1328072400000 , 4.1401512200522] , [ 1328158800000 , 4.6727018946707] , [ 1328245200000 , 5.2867004865128] , [ 1328331600000 , 5.2867004865128] , [ 1328418000000 , 5.2867004865128] , [ 1328504400000 , 5.3018888374398] , [ 1328590800000 , 5.1280880489145] , [ 1328677200000 , 5.4871623117969] , [ 1328763600000 , 5.9003310858354] , [ 1328850000000 , 5.0814183419277] , [ 1328936400000 , 5.0814183419277] , [ 1329022800000 , 5.0814183419277] , [ 1329109200000 , 5.2642419624752] , [ 1329195600000 , 4.8821179791227] , [ 1329282000000 , 4.5757484771430] , [ 1329368400000 , 5.3842423229681] , [ 1329454800000 , 5.8228981100571] , [ 1329541200000 , 5.8228981100571] , [ 1329627600000 , 5.8228981100571] , [ 1329714000000 , 5.8228981100571] , [ 1329800400000 , 5.9363351939783] , [ 1329886800000 , 5.8228361646391] , [ 1329973200000 , 6.0558840413572] , [ 1330059600000 , 5.9445876811563] , [ 1330146000000 , 5.9445876811563] , [ 1330232400000 , 5.9445876811563] , [ 1330318800000 , 6.1681584877353] , [ 1330405200000 , 6.3035995639854] , [ 1330491600000 , 5.6363506399283]]
|
|
},
|
|
{
|
|
key: "Average Exposure Return" ,
|
|
values: [ [ 1317614400000 , -1.4090582224638] , [ 1317700800000 , -0.33947919866996] , [ 1317787200000 , 1.3209670502436] , [ 1317873600000 , 2.4188464341509] , [ 1317960000000 , 1.0255951936249] , [ 1318046400000 , 1.0255951936249] , [ 1318132800000 , 1.0255951936249] , [ 1318219200000 , 2.6899883270271] , [ 1318305600000 , 2.8018416928856] , [ 1318392000000 , 3.8403942243892] , [ 1318478400000 , 3.5468986968984] , [ 1318564800000 , 4.0243375950513] , [ 1318651200000 , 4.0243375950513] , [ 1318737600000 , 4.0243375950513] , [ 1318824000000 , 2.4581180602808] , [ 1318910400000 , 4.1316695396727] , [ 1318996800000 , 3.1991658519074] , [ 1319083200000 , 3.3754265861117] , [ 1319169600000 , 4.4804434889521] , [ 1319256000000 , 4.4804434889521] , [ 1319342400000 , 4.4804434889521] , [ 1319428800000 , 6.0509760703797] , [ 1319515200000 , 4.5220450819341] , [ 1319601600000 , 5.4035696887952] , [ 1319688000000 , 8.5378579094975] , [ 1319774400000 , 8.3016796632707] , [ 1319860800000 , 8.3016796632707] , [ 1319947200000 , 8.3016796632707] , [ 1320033600000 , 6.2091232673734] , [ 1320120000000 , 4.6685577522987] , [ 1320206400000 , 5.6873278908841] , [ 1320292800000 , 6.1826552943765] , [ 1320379200000 , 6.0959959548027] , [ 1320465600000 , 6.0959959548027] , [ 1320552000000 , 6.0959959548027] , [ 1320642000000 , 6.4745420383103] , [ 1320728400000 , 6.6925431963260] , [ 1320814800000 , 4.0430621035979] , [ 1320901200000 , 4.2956347789229] , [ 1320987600000 , 5.5492974385965] , [ 1321074000000 , 5.5492974385965] , [ 1321160400000 , 5.5492974385965] , [ 1321246800000 , 5.0642000641245] , [ 1321333200000 , 5.6666120553597] , [ 1321419600000 , 4.6202390103380] , [ 1321506000000 , 3.0124066565603] , [ 1321592400000 , 2.8681458220660] , [ 1321678800000 , 2.8681458220660] , [ 1321765200000 , 2.8681458220660] , [ 1321851600000 , 1.6604177140523] , [ 1321938000000 , 1.3391308252236] , [ 1322024400000 , -0.1027204753207] , [ 1322110800000 , -0.1027204753207] , [ 1322197200000 , -0.4062707232214] , [ 1322283600000 , -0.4062707232214] , [ 1322370000000 , -0.4062707232214] , [ 1322456400000 , 0.5651520529190] , [ 1322542800000 , 0.1114911016548] , [ 1322629200000 , 2.2135818365753] , [ 1322715600000 , 1.9445161544187] , [ 1322802000000 , 1.9427980090936] , [ 1322888400000 , 1.9427980090936] , [ 1322974800000 , 1.9427980090936] , [ 1323061200000 , 2.3501860364827] , [ 1323147600000 , 2.1136672636407] , [ 1323234000000 , 2.2418743103244] , [ 1323320400000 , 1.0064931140733] , [ 1323406800000 , 1.9661258515092] , [ 1323493200000 , 1.9661258515092] , [ 1323579600000 , 1.9661258515092] , [ 1323666000000 , 1.0175542221399] , [ 1323752400000 , 0.5024676440828] , [ 1323838800000 , -0.6545437495700] , [ 1323925200000 , -0.8689652158149] , [ 1324011600000 , -0.7645004652824] , [ 1324098000000 , -0.7645004652824] , [ 1324184400000 , -0.7645004652824] , [ 1324270800000 , -1.7880862317039] , [ 1324357200000 , -0.1461682112898] , [ 1324443600000 , -0.5871487877962] , [ 1324530000000 , 0.2867400066741] , [ 1324616400000 , 0.7000618003773] , [ 1324702800000 , 0.7000618003773] , [ 1324789200000 , 0.7000618003773] , [ 1324875600000 , 0.7000618003773] , [ 1324962000000 , 0.4859463316191] , [ 1325048400000 , -0.4119526235861] , [ 1325134800000 , 0.2230991860845] , [ 1325221200000 , 0.1595400012524] , [ 1325307600000 , 0.1595400012524] , [ 1325394000000 , 0.1595400012524] , [ 1325480400000 , 0.1595400012524] , [ 1325566800000 , 1.2638744291023] , [ 1325653200000 , 1.1480591676914] , [ 1325739600000 , 1.4876618741657] , [ 1325826000000 , 1.6476476765120] , [ 1325912400000 , 1.6476476765120] , [ 1325998800000 , 1.6476476765120] , [ 1326085200000 , 2.1063050593731] , [ 1326171600000 , 2.5653649043989] , [ 1326258000000 , 2.8466857983576] , [ 1326344400000 , 3.0747141460071] , [ 1326430800000 , 2.4992620202541] , [ 1326517200000 , 2.4992620202541] , [ 1326603600000 , 2.4992620202541] , [ 1326690000000 , 2.4992620202541] , [ 1326776400000 , 2.2880782376570] , [ 1326862800000 , 3.1353436274553] , [ 1326949200000 , 3.5677616820370] , [ 1327035600000 , 3.5059469003623] , [ 1327122000000 , 3.5059469003623] , [ 1327208400000 , 3.5059469003623] , [ 1327294800000 , 3.6741640726128] , [ 1327381200000 , 3.5476135299444] , [ 1327467600000 , 3.8207752112587] , [ 1327554000000 , 3.8616315638872] , [ 1327640400000 , 4.3254831376284] , [ 1327726800000 , 4.3254831376284] , [ 1327813200000 , 4.3254831376284] , [ 1327899600000 , 4.0133484282063] , [ 1327986000000 , 4.0086992762233] , [ 1328072400000 , 4.6741072621578] , [ 1328158800000 , 5.1853600238372] , [ 1328245200000 , 5.7164828688020] , [ 1328331600000 , 5.7164828688020] , [ 1328418000000 , 5.7164828688020] , [ 1328504400000 , 5.7706486616140] , [ 1328590800000 , 5.5821721041319] , [ 1328677200000 , 5.9281978759001] , [ 1328763600000 , 6.3202608081270] , [ 1328850000000 , 5.4952215782126] , [ 1328936400000 , 5.4952215782126] , [ 1329022800000 , 5.4952215782126] , [ 1329109200000 , 5.6378737590063] , [ 1329195600000 , 5.2228974160623] , [ 1329282000000 , 4.8974412407240] , [ 1329368400000 , 5.7203603398934] , [ 1329454800000 , 6.1518150836713] , [ 1329541200000 , 6.1518150836713] , [ 1329627600000 , 6.1518150836713] , [ 1329714000000 , 6.1518150836713] , [ 1329800400000 , 6.2799444735621] , [ 1329886800000 , 6.1985966532271] , [ 1329973200000 , 6.3441512518544] , [ 1330059600000 , 6.2162658382840] , [ 1330146000000 , 6.2162658382840] , [ 1330232400000 , 6.2162658382840] , [ 1330318800000 , 6.4153940933982] , [ 1330405200000 , 6.5112028076997] , [ 1330491600000 , 5.8186218494908]]
|
|
}
|
|
].map(function(line) {
|
|
line.values = line.values.map(function(d) { return {x: d[0], y: d[1]/100 }})
|
|
.filter(function(d) {
|
|
var day = (new Date(d.x)).getDay();
|
|
return day != 0 && day != 6; //get rid of weekends for this example
|
|
});
|
|
return line;
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nv.charts.lineChartDaily()
|
|
.selector('#chart1')
|
|
//.data(sinAndCos())
|
|
.data(cumulativeDailyTestData)
|
|
.build();
|
|
|
|
|
|
|
|
|
|
function sinAndCos() {
|
|
var sin = [],
|
|
cos = [],
|
|
r1 = Math.random(),
|
|
r2 = Math.random();
|
|
|
|
for (var i = 0; i < 100; i++) {
|
|
sin.push({x: i, voltage: r2 * Math.sin(i/10)});
|
|
cos.push({x: i, voltage: r1 * Math.cos(i/10)});
|
|
}
|
|
|
|
return [
|
|
{
|
|
values: sin,
|
|
key: "Sine Wave",
|
|
color: "#ff7f0e"
|
|
},
|
|
{
|
|
values: cos,
|
|
key: "Cosine Wave",
|
|
color: "#2ca02c"
|
|
}
|
|
];
|
|
}
|
|
|
|
|
|
</script>
|