/** * @author Frédéric * @copyright 2015 */ function events( p1, p2 ) { j = 1; //count steps var points_qty = p2 - p1; coefStepY_news = (SymexChartGlobals.max_[0] - SymexChartGlobals.min_[0]) / SymexChartGlobals.chart_height; for( var i = eval(p1); i < eval(p2); i++ ) { if ( data_events[i] ){ var tmp_close = 0; for (var i2 = i; i2 >= p1; i2--) { if(SymexChartGlobals.type_curve == "C"){ if ( data_close_0[i2] ) { tmp_close = data_close_0[i2]; break; } }else if(SymexChartGlobals.type_curve == "K"){ if ( data_close_0[i2] ) { tmp_close = data_close_0[i2]; break; } }else{ if ( data_high_0[i2] ) { tmp_close = data_high_0[i2]; break; } } } var new_div = document.createElement("div"); if(i < data_close_0.length){ var triangleColor = "#000000"; }else{ var triangleColor = "#2c61ea"; } $( new_div ).css({ position: "absolute", width: 0, height: 0, overflow: "hidden", cursor: "pointer", zIndex: 903, borderLeft: "5px solid transparent", borderRight: "5px solid transparent", borderTop: "10px solid " + triangleColor }); document.getElementById('priceGraph').appendChild(new_div); var pos = SymexChartGlobals.stepX * j - SymexChartGlobals.stepX -5 ; //5 => half of triangle image stepY_news = (SymexChartGlobals.max_[0] - tmp_close) / coefStepY_news -30;//10px above the point if(stepY_news < 0){ stepY_news = (SymexChartGlobals.max_[0] - data_low_0[i2]) / coefStepY_news;//10px above the point } new_div.style.left = pos.toFixed(0) + 'px'; new_div.style.top = stepY_news + 'px'; // Add left position in class new_div.className = " left_" + parseInt(pos); new_div.className += " triangle"; new_div.id = i; new_div.onmouseover = function() { val_key2_ = []; Object.keys(data_events[this.id]).forEach(function(cle){ val_key2_.push(cle); }); val_key = val_key2_[0]; /* var href; href = "P4"; href = href.replace( "P1", this.id ); href = href.replace( "P2", data_news[ this.id ][val_key][2] ); href = href.replace( "P3", data_news[ this.id ][val_key][4] ); href = href.replace( "P4", SymexChartSettings.lang_array[22] ); href = href.replace( "P5", data_news[ this.id ][val_key][3] ); href = href.replace( "P6", data_news[ this.id ][val_key][6] ); href = " " + href; */ // Take in mind space for pointer (triangle img) and date (12px) // 7.5 - theorical width of a letter var headlineSize = parseInt( SymexChartGlobals.chart_width / 7.5 - 12 ); var pointerColor = "#2c61ea"; var headlinePointer = $( "
" ).css({ position: "absolute", width: 0, height: 0, overflow: "hidden", cursor: "pointer", zIndex: 903, borderTop: "5px solid transparent", borderBottom: "5px solid transparent", borderLeft: "10px solid " + pointerColor, }); var headline = headlinePointer.prop( "outerHTML" ) + " "; headline += ""+date_eu( data_events[this.id][val_key][2] ) + ": "; headline += data_events[this.id][val_key][3]+"" ; //headline += href; $("#news-info").css("left",($("#period_chart").width()+15)); document.getElementById( "news-info" ).innerHTML = headline; }; new_div.onmouseout = function() { document.getElementById( "news-info" ).innerHTML = " "; }; } j++; } }