Display stock quotes from Yahoo!: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary  | 
				A WASSERMANN (talk | contribs) No edit summary  | 
				||
| Line 11: | Line 11: | ||
<jsxgraph width="700" height="400">  | <jsxgraph width="700" height="400">  | ||
var hi, lo, brd, periodical,    | var hi, lo, brd, periodical,    | ||
     brd, g, txt,  |      brd, g, txt, val,  | ||
     x = [],  |      x = [],  | ||
     y = [];  |      y = [];  | ||
| Line 25: | Line 25: | ||
                 x.push(x.length+1);  |                  x.push(x.length+1);  | ||
                 y.push(a[1]);  |                  y.push(a[1]);  | ||
                val = a[1];  // set the text  | |||
                 if (!g) {    |                  if (!g) {    | ||
                     g = brd.createElement('curve', [x,y],{strokeWidth:3, strokeColor:'green'});    |                      g = brd.createElement('curve', [x,y],{strokeWidth:3, strokeColor:'green'});    | ||
                     txt = brd.createElement('text', [3,(hi+lo)*0.5,  |                      txt = brd.createElement('text', [3,(hi+lo)*0.5,function(){return 'GDAXI = '+val;}],{fontSize:'14px'});    | ||
                 } else {  |                  } else {  | ||
                     g.dataX = x;                       |                      g.dataX = x;                       | ||
                     g.dataY = y;  |                      g.dataY = y;  | ||
                 }  |                  }  | ||
                 brd.update();  |                  brd.update();  | ||
Revision as of 14:18, 20 August 2009
This JSXGraph application fetches the live stock quotes of the German DAX Index (gdaxi) from Yahoo!. The curve is updated only once a second, so initially it needs a little patience until the curve is visible.