Changeset 09ae4afdafa468e6bf38830e913189e5878ae130
- Timestamp:
- 03/10/09 16:50:52
(4 years ago)
- Author:
- Umar Farooq <umar@omniti.com>
- git-committer:
- Umar Farooq <umar@omniti.com> 1236703852 +0000
- git-parent:
[dc414cff50ce974e1b64ce24d6be49d5c0c70a83]
- git-author:
- Umar Farooq <umar@omniti.com> 1236703852 +0000
- Message:
times now come from the DB in UTC, and are displayed by flot in local time, using the new xaxis.localtime option
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| re13f962 |
r09ae4af |
|
| 41 | 41 | minTickSize: null, // number or [number, "unit"] |
|---|
| 42 | 42 | monthNames: null, // list of names of months |
|---|
| 43 | | timeformat: null // format string to use |
|---|
| | 43 | timeformat: null, // format string to use |
|---|
| | 44 | localtime: null //display data in local time instead of UTC default |
|---|
| 44 | 45 | }, |
|---|
| 45 | 46 | yaxis: { |
|---|
| … | … | |
| 434 | 435 | for (var i = 0; i < fmt.length; ++i) { |
|---|
| 435 | 436 | var c = fmt.charAt(i); |
|---|
| 436 | | |
|---|
| 437 | 437 | if (escape) { |
|---|
| 438 | 438 | switch (c) { |
|---|
| 439 | | case 'h': c = "" + d.getUTCHours(); break; |
|---|
| 440 | | case 'H': c = leftPad(d.getUTCHours()); break; |
|---|
| 441 | | case 'M': c = leftPad(d.getUTCMinutes()); break; |
|---|
| 442 | | case 'S': c = leftPad(d.getUTCSeconds()); break; |
|---|
| 443 | | case 'd': c = "" + d.getUTCDate(); break; |
|---|
| 444 | | case 'm': c = "" + (d.getUTCMonth() + 1); break; |
|---|
| 445 | | case 'y': c = "" + d.getUTCFullYear(); break; |
|---|
| 446 | | case 'b': c = "" + monthNames[d.getUTCMonth()]; break; |
|---|
| | 439 | case 'h': c = "" + ((axisOptions.localtime) ? d.getHours() : d.getUTCHours()); break; |
|---|
| | 440 | case 'H': c = leftPad( ((axisOptions.localtime) ? d.getHours() : d.getUTCHours()) ); break; |
|---|
| | 441 | case 'M': c = leftPad( ((axisOptions.localtime) ? d.getMinutes() : d.getUTCMinutes()) ); break; |
|---|
| | 442 | case 'S': c = leftPad( ((axisOptions.localtime) ? d.getSeconds() : d.getUTCSeconds()) ); break; |
|---|
| | 443 | case 'd': c = "" + ( (axisOptions.localtime) ? d.getDate() : d.getUTCDate() ); break; |
|---|
| | 444 | case 'm': c = "" + ( (axisOptions.localtime) ? d.getMonth() +1 : d.getUTCMonth() +1 ); break; |
|---|
| | 445 | case 'y': c = "" + ( (axisOptions.localtime) ? d.getFullYear() : d.getUTCFullYear() ); break; |
|---|
| | 446 | case 'b': c = "" + monthNames[ ( (axisOptions.localtime) ? d.getMonth() : d.getUTCMonth() ) ]; break; |
|---|
| 447 | 447 | } |
|---|
| 448 | 448 | r.push(c); |
|---|
| … | … | |
| 527 | 527 | tickSize = axis.tickSize[0], unit = axis.tickSize[1], |
|---|
| 528 | 528 | d = new Date(axis.min); |
|---|
| 529 | | |
|---|
| | 529 | |
|---|
| 530 | 530 | var step = tickSize * timeUnitSize[unit]; |
|---|
| 531 | 531 | |
|---|
| r462702b |
r09ae4af |
|
| 307 | 307 | return val.toFixed(axis.tickDecimals) + r.options.yaxis.suffix; |
|---|
| 308 | 308 | }; |
|---|
| | 309 | r.options.xaxis.localtime = true; |
|---|
| 309 | 310 | doptions = r.options; |
|---|
| 310 | 311 | dplaceholder = placeholder; |
|---|
| r462702b |
r09ae4af |
|
| 23 | 23 | "prism", "prism"); |
|---|
| 24 | 24 | $this->db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); |
|---|
| | 25 | $sth = $this->db->prepare("set timezone to 'UTC'"); |
|---|
| | 26 | $sth->execute(); |
|---|
| | 27 | |
|---|
| 25 | 28 | } |
|---|
| 26 | 29 | function prepare($sql) { |
|---|
| … | … | |
| 31 | 34 | function get_data_for_window($uuid, $name, $start, $end, $expected, $derive) { |
|---|
| 32 | 35 | $type = preg_match('/^\d+$/', $uuid) ? '::integer' : '::uuid'; |
|---|
| 33 | | $sth = $this->db->prepare(" |
|---|
| 34 | | select sid, name, extract(epoch from |
|---|
| 35 | | (rollup_time::timestamp::text || '-00') |
|---|
| 36 | | ::timestamptz) as rollup_time, |
|---|
| | 36 | $dsql = "select sid, name, extract(epoch from |
|---|
| | 37 | rollup_time) as rollup_time, |
|---|
| 37 | 38 | count_rows, avg_value, counter_dev |
|---|
| 38 | 39 | from stratcon.fetch_dataset( |
|---|
| 39 | | ? $type,?, |
|---|
| 40 | | $this->time_kludge, |
|---|
| 41 | | $this->time_kludge, |
|---|
| 42 | | ?,? |
|---|
| 43 | | )"); |
|---|
| | 40 | ? $type,?,?,?,?,?)"; |
|---|
| | 41 | $sth = $this->db->prepare($dsql); |
|---|
| 44 | 42 | $sth->execute(array($uuid,$name,$start,$end,$expected,$derive)); |
|---|
| 45 | 43 | $rv = array(); |
|---|
| … | … | |
| 52 | 50 | $type = preg_match('/^\d+$/', $uuid) ? "::int" : "::uuid"; |
|---|
| 53 | 51 | $sth = $this->db->prepare(" |
|---|
| 54 | | select sid, extract(epoch from |
|---|
| 55 | | (whence::timestamp::text || '-00') |
|---|
| 56 | | ::timestamptz) as whence, |
|---|
| | 52 | select sid, extract(epoch from whence) as whence, |
|---|
| 57 | 53 | name, value |
|---|
| 58 | 54 | from stratcon.fetch_varset( |
|---|
| 59 | | ? $type,?,$this->time_kludge,$this->time_kludge,? |
|---|
| 60 | | )"); |
|---|
| | 55 | ? $type,?,?,?,?)"); |
|---|
| 61 | 56 | $sth->execute(array($uuid,$name,$start,$end,$expected)); |
|---|
| 62 | 57 | $rv = array(); |
|---|