var hvChart={lang:null,chart:null,cur_chart:null,data:null,colors:{ulast:"rgba(43,141,255,0.7)",iv:"#20c997",hv10:"#ffc720",hv30:"#fd7e14",hv60:"#6f42c1",hv90:"#ff4866"},navigatorUpdated:null,toolTipMoved:null,selectedRange:[-1,-1],stockcode:"",ucode:'',comparecode:"",backgroundColor:"",selected_ts:0,loadingContainer:null,lastTooltipPoint:null,isMobile:false,chart_ishome:false,hv_lists:{primary:0,iv:1,hv10:2,hv30:3,hv60:4,hv90:5},init:function(ishome,ucode,callback,navUpdated,ttMoved){var self=this;self.navigatorUpdated=(navUpdated!==undefined)?navUpdated:null;self.toolTipMoved=(ttMoved!==undefined)?ttMoved:null;url='/'+lang+'/data/chart/hvChart';url+=(ishome!==undefined&&ishome!="")?'/ishome/'+ishome:'';url+=(ucode!==undefined&&ucode!="")?'/ucode/'+ucode:'';$.getJSON(url,function(_data){self.data=self.decode(_data);var htmlContainer=null;if($('#hvChartContainer .highcharts-html-container').length>0){htmlContainer=$('#hvChartContainer .highcharts-html-container')}if(ishome!==undefined&&ishome!=""){$('#iv_chng').html(_data.udata.iv_pchng);$('#iv_data').html(_data.udata.iv);$('#iv_stime').html(_data.sdate);this.chart_ishome=1}$('#hvChartContainer').highcharts('StockChart',self.getJSON(self.data),function(chart){if($(chart.renderTo).attr("id")){if(!$('#hvChartContainer').hasClass("noSetting")){if(htmlContainer){$('#hvChartContainer').append(htmlContainer)}else{$('#hvChartContainer').append("
")}}self.isDesktop=($(window).width()>767)?1:0;self.chart=chart;self.cur_chart=chart;if(_data.mainData.length>0){self.setPeriod(self.data.ulast[0][0],self.data.ulast[self.data.ulast.length-1][0]);$("#content-hv .timer").html(self.labels()[lang].lastupdate+_data.sdate)}if(callback){callback()}}else{chart.reflow()}$.each(self.hv_lists,function(index,value){if(!$('#'+index).prop("checked"))hvChart.chart.series[value].update({visible:false})});$("input[name='hv']").click(function(){let id=$(this).attr("id");let pos=self.hv_lists[id];let status=$(this).prop("checked");hvChart.chart.series[pos].update({visible:status});if(!$("input[name='hv']:checked").val()){$('#primary').click()}});$('#primary').click(function(){if($("#primary").is(":checked")){hvChart.chart.yAxis[1].update({gridLineWidth:0})}else{hvChart.chart.yAxis[1].update({gridLineWidth:1})}})})})},decode:function(_data){var data=_data.mainData;var ulast=[],iv=[],hv10=[],hv30=[],hv60=[],hv90=[];for(i=0;i0?data[i].ulast:null)]);iv.push([data[i].ts,(data[i].iv>0?data[i].iv:null)]);hv10.push([data[i].ts,(data[i].hv10>0?data[i].hv10:null)]);hv30.push([data[i].ts,(data[i].hv30>0?data[i].hv30:null)]);hv60.push([data[i].ts,(data[i].hv60>0?data[i].hv60:null)]);hv90.push([data[i].ts,(data[i].hv90>0?data[i].hv90:null)])}return{ulast:ulast,iv:iv,hv10:hv10,hv30:hv30,hv60:hv60,hv90:hv90}},options:{groupingUnits:[['day',[1]],],chartHeight:($(window).width()>767)?325:(($(window).width()<325)?290:305),chartTop:($(window).width()>767)?40:(($(window).width()<325)?70:55),},getJSON:function(data){var self=this;var SetUp={home:{height:80,lineWidth:1,gridLineColor:'#e6e6e6',lineColor:'rgba(43,141,255,0.7)',tickAmount:4,xTitle:{enabled:false},xLabel:{enabled:false},yTitle:{enabled:false},yLabel:{formatter:function(){return formatPrice(this.value)},style:{fontSize:"9px",},align:"right",x:-9,y:5},yTitle2:{enabled:false},yLabelStyle:{fontSize:"9px",'color':'rgba(142,142,142,0.8)'},series:{name:'iv',type:'area',id:'iv',data:data.iv,yAxis:1,lineWidth:1.25,fillColor:{linearGradient:{x1:0,y1:0,x2:0,y2:1},stops:[[0,'rgba(43,141,255,0.3)'],[0.9,'rgba(43,141,255,0)']]},color:'rgba(43,141,255,0.7)',dataGrouping:{units:self.options.groupingUnits,groupPixelWidth:1000},}},inner:{height:$(window).width()<768?230:400,lineWidth:1,gridLineColor:'#ebedee',tickAmount:6,xTitle:{text:self.labels()[lang].xTitle,rotation:0,},xLabel:{formatter:function(){return Highcharts.dateFormat('%d/%m/%y',this.value)},style:{fontSize:"11px",},},yTitle:{text:" ",useHTML:true,rotation:(lang=='en')?-90:0,margin:15,x:0,y:(lang=='en')?-20:-50},yLabel:{formatter:function(){return formatPrice(this.value)},style:{fontSize:"12px",},align:"right",x:-9,y:5},yTitle2:{text:" ",useHTML:true,rotation:(lang=='en')?-90:0,margin:15,x:9,y:(lang=='en')?-20:-50},yLabelStyle:{fontSize:"12px",},series:{name:'iv',type:'line',id:'iv',data:data.iv,yAxis:1,lineWidth:1.25,color:this.colors['iv'],lineColor:this.colors['iv'],dataGrouping:{units:self.options.groupingUnits,groupPixelWidth:1000},}}};var page=$('body').hasClass('home-page')?'home':'inner';return{chart:{animation:true,height:SetUp[page].height,renderTo:'hvChartContainer',backgroundColor:'transparent',spacing:[0,0,0,0],marginTop:5,events:{load:function(){if(this==self.chart){}else{self.cur_chart=this;setTimeout(function(){self.cur_chart=self.chart},100)}},redraw:function(event){if((self.selectedRange[0]!=event.target.xAxis[0].min||self.selectedRange[1]!=event.target.xAxis[0].max)||(self.selectedRange[0]==-1&&self.selectedRange[1]==-1)){self.selectedRange[0]=event.target.xAxis[0].min;self.selectedRange[1]=event.target.xAxis[0].max;if(self.navigatorUpdated){self.navigatorUpdated(event.target.xAxis[0].min,event.target.xAxis[0].max)}}}}},annotationsOptions:{enabled:false,noButtons:true,},exporting:{enabled:false,},plotOptions:{area:{threshold:null,fillOpacity:0.1,lineWidth:2,},series:{lineWidth:1,states:{hover:{enabled:false,}}}},tooltip:{backgroundColor:"rgba(0,0,0,0)",borderWidth:0,borderRadius:0,useHTML:true,positioner:function(width,height,point){var pos=this.getPosition(width,height,point);pos.y=5;return pos},formatter:function(){var _html='
'+Highcharts.dateFormat('%Y-%m-%d',this.x)+'
';$.each(this.points,function(index,value){_html+='
'+hvChart.labels()[lang][value.series.name]+''+formatPrice(value.point.y)+'
'});return _html},shadow:false,},rangeSelector:{enabled:false,selected:1},navigator:{enabled:false,},scrollbar:{enabled:false},xAxis:{type:'datetime',gridLineWidth:0,lineWidth:0,tickColor:'#00000000',crosshair:{width:1,color:"#d6d6d6",zIndex:1,snap:true,},title:SetUp[page].xTitle,labels:SetUp[page].xLabel,},yAxis:[{title:SetUp[page].yTitle,labels:SetUp[page].yLabel,gridLineWidth:(self.toolTipMoved!=null)?0:1,crosshair:false,opposite:false,showFirstLabel:false,showLastLabel:true,},{title:SetUp[page].yTitle2,labels:{formatter:function(){return formatPrice((this.value).toFixed(0))},style:SetUp[page].yLabelStyle,align:'left',x:3,y:5,},gridLineColor:SetUp[page].gridLineColor,opposite:true,showFirstLabel:false,showLastLabel:true,gridLineWidth:1,tickPositioner:function(){var positions=[],tick_amount=SetUp[page].tickAmount,tick_min=(this.max-this.min)/tick_amount;tick_min=((this.max+tick_min)-this.min)/tick_amount;for(var i=0;i



格",yTitle2:"引



(%)",date:"",primary:"相關資產價格: ",iv:"IV: ",hv:"HV: ",hv10:"HV10: ",hv30:"HV30: ",hv60:"HV60: ",hv90:"HV90: ",xTitle:"日期",lastupdate:"最後更新時間: ",},sc:{unit:{K:"千",M:"百万",B:"十亿",},yTitle1:"相




格",yTitle2:"引



(%)",date:"",primary:"相关资产价格: ",iv:"IV: ",hv:"HV: ",hv10:"HV10: ",hv30:"HV30: ",hv60:"HV60: ",hv90:"HV90: ",xTitle:"日期",lastupdate:"最後更新时间: ",},en:{unit:{K:"K",M:"M",B:"B",},yTitle1:"Underlying Price",yTitle2:"Volatility (%)",date:" ",primary:"Underlying Price: ",iv:"IV: ",hv:"HV: ",hv10:"HV10: ",hv30:"HV30: ",hv60:"HV60: ",hv90:"HV90: ",xTitle:"Date",lastupdate:"Last updated:",},};return _out},}