?? logchart.xml
字號:
var grp = e.getTarget(); var type = grp.getSelected().logType; this.setLogType(type);};_p.setLogType = function (s) { if (this._logType != s) { this._logType = s; this.updateAsync("", true); //this.graph.fromXmlDocument( this.getGraphDocument() ); //this.graph.setChartType( this.getChartType() ); // override xml chart type //this.graph.update(); }};_p.getLogType = function () { return this._logType };_p.onTimeFrameChange = function (e) { var grp = e.getTarget(); var tf = grp.getSelected().timeFrame; this._toDate = null; this._fromDate = null; this.setTimeFrame(tf);};_p.getTimeFrame = function () { return this._timeFrame };_p.drillDown = function (oCategory) { var id = oCategory.getId(); var catEl = this.dataDocument.selectSingleNode("//*[@Id='" + id + "']"); var s = catEl.getAttribute("date"); var d = fromIsoDate(s); switch (this._timeFrame) { case "years": this.setTimeFrame("months", d); break; case "months": this.setTimeFrame("days", d); break; case "days": this.setTimeFrame("hours", d); break; }};_p.drillUp = function () { switch (this._timeFrame) { case "months": this.setTimeFrame("years"); break; case "days": this.setTimeFrame("months"); break; case "hours": this.setTimeFrame("days"); return; }};_p.setTimeFrame = function (sTimeFrame, oDate) { if (this._timeFrame != sTimeFrame) { if (!oDate) { if (this._fromDate != null && this._toDate != null) { oDate = new Date( (this._toDate.valueOf() + this._fromDate.valueOf()) / 2 ); } else { this._fromDate = null; this._toDate = null; } } if (oDate) { this._fromDate = new Date(oDate); this._toDate = new Date(oDate); switch (sTimeFrame) { case "hours": this._fromDate.setUTCHours(0); this._toDate.setUTCHours(0); this._toDate.setUTCDate( this._toDate.getUTCDate() + 1 ); break; case "days": this._fromDate.setUTCHours(0); this._toDate.setUTCHours(0); this._fromDate.setUTCDate(1); this._toDate.setUTCDate(1); this._toDate.setUTCMonth( this._toDate.getUTCMonth() + 1 ); break; case "months": this._fromDate.setUTCHours(0); this._toDate.setUTCHours(0); this._fromDate.setUTCDate(1); this._toDate.setUTCDate(1); this._fromDate.setUTCMonth(0); this._toDate.setUTCMonth(0); this._toDate.setUTCFullYear( this._toDate.getUTCFullYear() + 1 ); break; case "years": this._fromDate.setUTCHours(0); this._toDate.setUTCHours(0); this._fromDate.setUTCDate(1); this._toDate.setUTCDate(1); this._fromDate.setUTCMonth(0); this._toDate.setUTCMonth(0); this._fromDate.setUTCFullYear( this._fromDate.getUTCFullYear() - 5 ); this._toDate.setUTCFullYear( this._toDate.getUTCFullYear() + 5 ); break; } } this._timeFrame = sTimeFrame; this.timeFrameRadioGroup.setEnabled(false); switch (sTimeFrame) { case "years": this.timeFrameRadioGroup.setSelected(this.yearsMenuItem); break; case "months": this.timeFrameRadioGroup.setSelected(this.monthsMenuItem); break; case "days": this.timeFrameRadioGroup.setSelected(this.daysMenuItem); break; case "hours": this.timeFrameRadioGroup.setSelected(this.hoursMenuItem); break; } this.timeFrameRadioGroup.setEnabled(true); this.updateAsync("", true); //this.graph.fromXmlDocument( this.getGraphDocument() ); //this.graph.setChartType( this.getChartType() ); // override xml chart type //this.graph.update(); this._syncUpButtons(); }};_p._syncUpButtons = function () { this.upButton.setEnabled(this._timeFrame != "years"); this.upMenuItem.setEnabled(this._timeFrame != "years"); this.drillDownMenuItem.setEnabled(this._timeFrame != "hours"); this.upContextMenuItem.setEnabled(this._timeFrame != "years");};_p.getDataDocument = function () { return this.dataDocument = BiXmlLoader.load( LogChart.URI + "timeframe=" + this._timeFrame + "&logtype=" + this._logType + (this._fromDate ? "&from=" + toIsoDate(this._fromDate) : "") + (this._toDate ? "&to=" + toIsoDate(this._toDate) : "") );};_p.getPresentationDocument = function () { // no need to load twice if (this.presentationDocument) return this.presentationDocument; return this.presentationDocument = BiXmlLoader.load("presentation.xml");};_p.getGraphDocument = function () { var doc = this.getDataDocument(); var presDoc = this.getPresentationDocument(); // note that MSXML does not have importNode var presEl = presDoc.documentElement.cloneNode(true); doc.documentElement.appendChild(presEl); return doc;};_p.updateAsync = function (sMessage, bFetchDocument) { var t = new BiTimer(10); t.addEventListener("tick", function () { if (bFetchDocument) this.graph.fromXmlDocument( this.getGraphDocument() ); this.graph.setChartType( this.getChartType() ); // override xml chart type this.graph.update(); this.graph.setCursor("default"); application.getWindow().setCursor("default"); this.showTimeFrame(); t.dispose(); }, this); this.setStatus(sMessage || "Loading data"); this.graph.setCursor("wait"); application.getWindow().setCursor("wait"); t.start();};_p.setStatus = function (s) { this.statusPanel.setText( s );};var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];// This method shows the dates for the time frame in the status bar_p.showTimeFrame = function () { var catEls = this.dataDocument.getElementsByTagName("Category"); var l = catEls.length; var d0 = fromIsoDate(catEls[0].getAttribute("date")); var d1 = fromIsoDate(catEls[l-1].getAttribute("date")); var s = this.graph.getSeries()[0].getTitle() + " from "; switch (this._timeFrame) { case "years": s += d0.getUTCFullYear() + " to " + d1.getUTCFullYear(); break; case "months": s += months[d0.getUTCMonth()] + " " + d0.getFullYear() + " to " + months[d1.getUTCMonth()] + " " + d1.getFullYear(); break; case "days": s += d0.getUTCFullYear() + "-" + fillZeros(d0.getUTCMonth() + 1) + "-" + fillZeros(d0.getUTCDate()) + " to " + d1.getUTCFullYear() + "-" + fillZeros(d1.getUTCMonth() + 1) + "-" + fillZeros(d1.getUTCDate()); break; case "hours": s += d0.getUTCFullYear() + "-" + fillZeros(d0.getUTCMonth() + 1) + "-" + fillZeros(d0.getUTCDate()) + " " + fillZeros(d0.getUTCHours()) + ":00" + " to " + d1.getUTCFullYear() + "-" + fillZeros(d1.getUTCMonth() + 1) + "-" + fillZeros(d1.getUTCDate()) + " " + fillZeros(d1.getUTCHours() + 1) + ":00"; break; } this.setStatus(s);};// date functionsfunction fillZeros(n) { if (n < 10) return "0" + n; return String(n);}function toIsoDate(d) { return d.getUTCFullYear() + "-" + fillZeros(d.getUTCMonth() + 1) + "-" + // odd that month is 0-11 when everything else is 1-based fillZeros(d.getUTCDate()) + " " + fillZeros(d.getUTCHours()) + ":" + fillZeros(d.getUTCMinutes()) + ":" + fillZeros(d.getUTCSeconds()) + "Z";}// yyyy-MM-dd HH:mm:ssZ// 01234567890123456789function fromIsoDate(s) { var d = new Date; d.setUTCFullYear( s.substr(0,4) ); d.setUTCMonth( s.substr(5,2) - 1 ); d.setUTCDate( s.substr(8,2) ); d.setUTCHours( s.substr(11,2) ); d.setUTCMinutes( s.substr(14,2) ); d.setUTCSeconds( s.substr(17,2) ); d.setUTCMilliseconds( 0 ); return d;} ]]></script> </resources></application>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -