/** * uses _scripts/graphs.js * uses _scripts/standar/map.js */ var _debug = false; HistoricGraph.NOT_SORT = 0; HistoricGraph.SORT_ASC = 1; HistoricGraph.SORT_DES = 2; if(!HistoricGraph.myHistoricGraphs) HistoricGraph.myHistoricGraphs = new Array(); HistoricGraph.findHistoricGraph = function(idgraph){ return HistoricGraph.myHistoricGraphs[idgraph]; } HistoricGraph.msgs = new function(){ this.txt0="Intradia"; this.txt7="1 Semana"; this.txt15="2 Semana"; this.txt30="1 Mes"; this.txt90="3 Meses"; this.compareTwoRecords = "¿Desea comparar con el anterior warrant?"; this.createNewGraph = "Se va a crear un grafico nuevo\n ¿desea continuar?"; } HistoricGraph.clickTimeButtons = function(uniqueName,period,name){ HistoricGraph.findHistoricGraph(uniqueName).showHistoryGraph(period,name); } function HistoricGraph(uniqueName, graphAppletId, wsAppletId, div){ HistoricGraph.myHistoricGraphs[uniqueName] = this; this.uniqueName = uniqueName; this.rics = new Map(); this.graph = new GraphHandler(graphAppletId); this.graphAppletId = graphAppletId; this.wsAppletId = wsAppletId; this.graph.graphMenu.recordsCallbackMethod= '$$'+this.uniqueName+'_onGraphRecordMenuClicked'; this.wsApplet = null; this.divContent = div; this.showPopup = false; this.showTimeButtons = true; this.showTitle = true; this.showAxesLabels = true; this.__timeDateFormat = "hh:mm:ss"; this.__timeDateFormatWithoutSeconds = "hh:mm"; this.__dateDateFormat = "dd/MM/yy"; this.__datetimeDateFormat = "hh:mm:ss dd/MM/yy"; this.__lastButtonPressed = null; this.graphWidth = 400; this.graphHeight = 128; this.pending = 0; //create callback functions eval('$$'+this.uniqueName+'_onGraphCallback = function(key, str){ HistoricGraph.findHistoricGraph("'+uniqueName+'").onGraphCallback(key,str)}'); eval('$$'+this.uniqueName+'_onGraphException = function(key, type, msg){ HistoricGraph.findHistoricGraph("'+uniqueName+'").onGraphException(key, type, msg)}'); eval('$$'+this.uniqueName+'_onGraphLoad = function(){ HistoricGraph.findHistoricGraph("'+uniqueName+'").onGraphLoad()}'); eval('$$'+this.uniqueName+'_onGraphMenuClicked = function(menuText){ HistoricGraph.findHistoricGraph("'+uniqueName+'").onGraphMenuClicked(menuText)}'); eval('$$'+this.uniqueName+'_onGraphRecordMenuClicked = function(menuText,state){ HistoricGraph.findHistoricGraph("'+uniqueName+'").onGraphRecordMenuClicked(menuText,state)}'); eval('$$'+this.uniqueName+'_openCurrentGraph = function(){ HistoricGraph.findHistoricGraph("'+uniqueName+'").openCurrentGraph()}'); this.__currentlabel = "ask"; this.__title = ""; this.__currentperiod = 0; this.__currentFids = new Array(); this.__currentFids[0] = eval("__constants.FIDS."+ this.__currentlabel.toUpperCase()); this.__lastRics = new Array(); this.__lastRicNames = new Array(); this.__currentRics = new Array(); this.__currentRicNames = new Array(); this.__targets = new Array(); this.getTemporalData = function(rics, fids, target, num){ return this.getTemporalDataList('$$'+this.uniqueName+'_onGraphCallback', '$$'+this.uniqueName+'_onGraphException', rics, fids, target, num, HistoricGraph.SORT_ASC); } this.showGraph = function(records, recordNames, targets, period){ if(this.__currentRics[0] == records || (this.__currentRics.length==2 && this.__currentRics[1] == records)){ alert("Este warrant ya esta incluido "); return; }else if(this.__currentRics.length==1 && window.confirm(HistoricGraph.msgs.compareTwoRecords)){ this.__currentRics[1] = records; this.__currentRicNames[1] = recordNames; this.__targets.length = 1; }else if(this.__currentRics.length==2){ if(window.confirm(HistoricGraph.msgs.createNewGraph)){ this.__currentRics = records.split(','); this.__currentRicNames = recordNames.split(','); }else{ return; } }else{ this.__currentRics = records.split(','); this.__currentRicNames = recordNames.split(','); } if(targets){ this.__targets = targets.split('/'); } if(this.__targets.length==0) this.__targets = new Array('ask'); if(period){ this.__currentperiod = period; } if(_debug){ alert("LAST RICS " +this.__lastRics); alert("CURR RICS " +this.__currentRics); alert("TARGETS "+ this.__targets); } this.showGraphIntern(); } this.showGraphIntern = function() { var g = document.getElementById(this.graphAppletId); this.setLabelAndFids(); var YAxisLabelRight= ""; var aux = ""; if(this.showTitle){ if(this.title && !g){ this.__title= this.title; }else{ for (var i =0; i"; if(this.showPopup){ appCall = this.getHTMLPopupCode() + appCall; } if(this.showTimeButtons){ appCall += this.getHTMLButtonsCode(); } if(!this.divContent) this.divContent = "_Graficos_TAB"; document.getElementById(this.divContent).innerHTML = appCall; }else{ if(this.showTimeButtons){ if(this.__lastButtonPressed!= null) this.__lastButtonPressed.className = "button"; } this.showHistoryGraph(this.__currentperiod,HistoricGraph.msgs.txt0) } } this.removeGraph = function(nombre) { if(this.__currentRics.length==1){ return; } aux = new Array(); auxn = new Array(); for (var i =0; i0){ this.__currentlabel = this.__targets.join(',').toLowerCase(); for (var i =0; i'+HistoricGraph.msgs.txt0+''; appCall += ''+HistoricGraph.msgs.txt7+''; appCall += ''+HistoricGraph.msgs.txt15+''; appCall += ''+HistoricGraph.msgs.txt30+''; appCall += ''+HistoricGraph.msgs.txt90+''; appCall += ''; return appCall; } this.getHTMLPopupCode = function(){ var text; var isPopup = (opener != null && document.location.pathname.indexOf('index.jsp')==-1); if(isPopup) { text = ''+ ' '+ ' '+ ' '+ ' '+ '
Cerrar ventana

'; }else { link = '$$'+this.uniqueName+'_openCurrentGraph();return false;'; text = '
 Abrir en nueva ventana
'; } return text; } this.openCurrentGraph = function(){ wrts = escape(this.__currentRics.join(',')); fids = escape(this.__targets.join(',')); days = escape(this.__currentperiod); title = escape(this.__title); width = 600; height = 350; dresses = "height="+height+",width="+width+",location=no,scrollbars=no,menubars=no,toolbars=no,resizable=no"; window.open('popup/graph.jsp?warrants='+ wrts + '&fids=' + fids + '&days=' + days + '&height='+height+'&width='+ width + '&title=' + title ,'_blank',dresses ); } this.getTemporalDataList = function(metodo,metodoExcepcion, arrayRics, arrayFids, arrayTargets, days, sort) { if (days ==null || days == "") days = "0" if(_debug){ alert("rics "+arrayRics); alert("fields "+arrayTargets); } if(this.showAxesLabels){ this.writeAxesLabels(arrayRics,arrayTargets); } this.showMenus(); this.pending = arrayRics.length + arrayTargets.length -1; var id = ""; var rics = ""; for (var t =0; t1) this.graph.setYAxisLabelLeft(arrayTargets[1].toUpperCase()); else if(arrayRics.length>1) this.graph.setYAxisLabelLeft(arrayTargets[0].toUpperCase()); else this.graph.setYAxisLabelLeft(""); } this.showMenus = function(){ if(!this.graph.graphMenu.menuAdded){ this.graph.graphMenu.addAllMenuGraph(); this.graph.graphMenu.menuAdded = true; } this.removeRecordMenuItems(); this.addRecordMenuItems(); } this.removeRecordMenuItems = function(){ for (var t =0; t _times[i])) || (sorted==HistoricGraph.SORT_DES && (_times[j] < _times[i]))) { var aux = _times[j]; _times[j]=_times[i]; _times[i] = aux; aux = _values[j]; _values[j]=_values[i]; _values[i] = aux; } } } } strtimes = _times[0]; strvalues = _values[0]; for(var i=1; i<_times.length; i++){ if(_times[i]!=_times[i-1]) { strtimes+=","+_times[i]; strvalues+=","+_values[i]; } } } // Show the Values if(_debug) { alert(ric+ " "+ fid + " "+strtimes); alert(ric+ " "+ fid + " "+strvalues); } this.graph.addPoint(ric,fid,strtimes,strvalues); if((!numDays || numDays==0) && fid<10000) this.graph.finishedDownload(ric,fid); this.pending--; if(this.pending==0) this.graph.setLoading(false); } this.onGraphException = function(key, type, msg) { alert("HTTP : " + msg); } this.onGraphLoad = function(){ this.showHistoryGraph(this.__currentperiod,HistoricGraph.msgs.txt0); } this.onGraphMenuClicked = function(menuText) { // strip the non-breaking spaces from the display names // n.b. checking for ' ' will not work here var strippedText = ''; var strPos = 0; var calc = menuText.substr(0); // because menuText isn't a real javascript string! while(strPos < calc.length) { if(calc.charCodeAt(strPos) != 160) strippedText += calc.charAt(strPos); strPos++; } calculo=1; if(strippedText == "SinCalculo") strippedText = "None"; else if(strippedText == "MediaMovil") strippedText = "MovingAverage"; else if(strippedText == "MediaMovilporPesos") strippedText = "WeightedMovingAverage"; else if(strippedText == "MediaMovilExponencial") strippedText = "ExponentialMovingAverage"; else if(strippedText == "Momento") strippedText = "Momentum"; else if(strippedText == "MACD") strippedText = "MACD"; else if(strippedText == "RSI") strippedText = "RSI"; else calculo=0 if (calculo==1) { // update the graph this.graph.viewCalculation(idgraph, strippedText, "#ADBD00"); }else{ this.showHistoryGraph(strippedText) } } this.onGraphRecordMenuClicked = function( menuText, state ){ this.removeGraph(menuText); } }