Difference between revisions of "Time series II"

From JSXGraph Wiki
Jump to navigationJump to search
Line 3: Line 3:
 
<jsxgraph width="600" height="400">
 
<jsxgraph width="600" height="400">
 
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-1,4500,50,2500]});
 
var brd = JXG.JSXGraph.initBoard('jxgbox', {boundingbox:[-1,4500,50,2500]});
brd.create('axis',[[0,2600],[1,2600]]);
+
brd.create('axis',[[0,2700],[1,2700]]);
 
brd.create('axis',[[0,0],[0,1]]);
 
brd.create('axis',[[0,0],[0,1]]);
 +
 +
var toDate = function(datestr) {
 +
        var a = datestr.split('.');
 +
        return new Date(a[2],a[1],a[0]);
 +
    };
 +
 +
var table = [
 +
  ['9.1.2009',3250],
 +
  ['15.1.2009',3200],
 +
  ['17.1.2009',3200],
 +
  ['18.1.2009',3210],
 +
  ['20.1.2009',3250],
 +
  ['23.1.2009',3400],
 +
  ['27.1.2009',3590],
 +
  ['31.1.2009',3750],
 +
  ['3.2.2009',3810]
 +
  ];
 +
var i, x = [], y = [],
 +
    birthday = toDate(table[0][0]);
 +
 +
for (i=0;i<table.length;i++) {
 +
    x[i] = Math.floor(((toDate(table[i][0])).getTime()-birthday.getTime())/(1000.0*60.0*60.0*24.0));
 +
    y[i] = table[i][1]*1;
 +
}
 +
var c = brd.create('curve',[x,y]);
 +
 
</jsxgraph>
 
</jsxgraph>

Revision as of 17:52, 3 February 2010

The weight of Antonia Wassermann