var searchIntradayChart = { chart : null, type : null, fromdate : null, todate : null, mode : "desktop", container : "", lineWidth: 2, notHK: false, isFx: 0, code:null, backgroundColor:"#ffffff", init : function(code){ var self = this; self.labels["edu"] = self.labels["zh_cn"]; self.labels["zh-hk"] = self.labels["zh_hk"]; self.labels["en-hk"] = self.labels["en_hk"]; self.labels["zh-cn"] = self.labels["zh_cn"]; self.labels["edu-zh_hk"] = self.labels["zh_hk"]; self.labels["edu-en_hk"] = self.labels["en_hk"]; self.labels["edu-zh_cn"] = self.labels["zh_cn"]; self.code = code; $.getJSON('/?q=/'+lang+'/data/chart/intradayChart/code/'+code, function(_data) { var data = self.decode(_data); $((self.container=='')?'#searchIntradayChartContainer':'#'+self.container).highcharts('StockChart',self.getJSON(data), function (chart){ self.chart = chart; self.drawBackground(); }); }); }, decode : function(_data){ return _data.mainData; }, colors : {line1 : "#4D7AA7", line2 : "#ed8b00"}, margin : {mobile: 70, desktop: 100}, getJSON : function(data){ var self = this; var max = data.max; var min = data.min; var last = data.last; var lastc = data.lastc; var turnover = data.turnover; var volume = data.volume; var turnover_unit = data.turnover_unit; self.isFx = data.isFx; self.notHK = data.isUS; var y_visible = true; if(last.length>0){ var last_date = Highcharts.dateFormat('%Y-%m-%d', last[0][0]); var endTime = new Date(last_date+' 17:00:00 GMT').getTime(); for (var i=0;i-1) { self.halfday = false; } }; }else{ y_visible = false; } return { chart : { useHTML: true, plotBorderWidth: 0, marginTop: 0, marginRight: (y_visible)?45:0, marginLeft: 0, marginBottom:25, height: 90, backgroundColor: self.backgroundColor, //width: 285, events: { redraw: function(event) { self.redraw(); } } }, plotOptions: { series: { grouping: false, fillOpacity: 0.2, connectNulls: true } }, tooltip: { useHTML: true, formatter: function() { var _html = '
'+Highcharts.dateFormat('%Y-%m-%d', this.x)+' '+Highcharts.dateFormat('%H:%M', this.x)+''; var _index = this.points[0].point.index; if (this.points[0].point.dataGroup){ _index = this.points[0].point.dataGroup.start; } if(last[_index][1]==null){ $((self.container=='')?'#searchIntradayChartContainer':'#'+self.container).find(".highcharts-tooltip").hide(); }else{ $((self.container=='')?'#searchIntradayChartContainer':'#'+self.container).find(".highcharts-tooltip").show(); } if(last[_index][1]!=null){ _html += '
'+self.labels[lang].price+': '+ addcomma(last[_index][1])+''; }else{ _html += '
'+self.labels[lang].price+': - '; } if(turnover[_index]!=null && turnover[_index]!=0){ _html += '
'+self.labels[lang].turnover+': '+turnover[_index]+''; }else if(volume[_index]!=null && volume[_index]!=0){ _html += '
'+self.labels[lang].volume+': '+volume[_index]+''; }else{ _html += '
'+self.labels[lang].turnover+': - '; } return _html; }, }, rangeSelector : { inputEnabled:false, enabled: false }, xAxis:[ { type: 'datetime', gridLineWidth: 0, lineWidth: 0, tickWidth: 0, tickColor: '#ddd', lineColor: '#ddd', tickmarkPlacement: 'on', labels: { style: {color: "#000",textOverflow: 'none'}, rotation: 0, formatter : function() { //var value = Highcharts.dateFormat('%H:%M', this.value); var value = Highcharts.dateFormat('%H:%M', this.value); if (self.halfday || self.notHK) { if (typeof isDST == "function" && isDST()){ if (value.indexOf('06:00')>-1) { return '6:00'; }else if (value.indexOf('05:00')>-1) { return '5:00'; } }else{ if (value.indexOf('07:00')>-1) { return '7:00'; }else if (value.indexOf('06:00')>-1) { return '6:00'; } } return value; }else if(self.isFx==1){ return value; } else if((self.code).toUpperCase()=="MSCI" || (self.code).toUpperCase()=="MCA"){ var sec = Highcharts.dateFormat('%S', this.value)*1; if (value.indexOf('09:00')>-1||value.indexOf('11:00')>-1||value.indexOf('12:00')>-1|| value.indexOf('14:00')>-1||value.indexOf('16:00')>-1||value.indexOf('17:00')>-1) { return ''; } else if(sec>=0 && sec<=10){ if (value.indexOf('13:00')>-1) { return '12/13'; } return value; } else { return ''; } } else { if (value.indexOf('12:00')>-1||value.indexOf('09:00')>-1||value.indexOf('17:00')>-1) { return ''; } else if (value.indexOf('13:00')>-1) { return '12/13'; } else { return value; } } } }, tickPositioner: function () { //tickPositioner for daily var positions = []; var msec = 60*60*1000; var lastday = 0; if (self.notHK){ for (i=0;i-1 || value.indexOf('12:00')>-1 || value.indexOf('18:00')>-1 || value.indexOf('00:00')>-1 || value.indexOf('05:00') >-1){ positions.push(data.last[i][0]); } }else{ if( value.indexOf('07:00')>-1 || value.indexOf('12:00')>-1 || value.indexOf('18:00')>-1 || value.indexOf('00:00')>-1 || value.indexOf('06:00') >-1){ positions.push(data.last[i][0]); } } } }else if(self.isFx==1){ for (i=0;i-1 || value.indexOf('12:0')>-1 || value.indexOf('17:0')>-1 || value.indexOf('23:0')>-1){ positions.push(data.last[i][0]);console.log(value); } } }else if((self.code).toUpperCase()=="MSCI" || (self.code).toUpperCase()=="MCA"){ for (i=0;i-1 || value.indexOf('13:00')>-1 || value.indexOf('15:00')>-1 || value.indexOf('18:00')>-1 || value.indexOf('22:00')>-1 || value.indexOf('02:00')>-1){ positions.push(data.last[i][0]); } } }else if(!$('.desktop_only').is(':visible')){ for (i=0;i-1 || value.indexOf('13:00')>-1 || value.indexOf('16:00')>-1){ positions.push(data.last[i][0]); } } }else{ for (i=0;i-1||value.indexOf('09:')>-1||value.indexOf('17:00')>-1)) { if (lastday != _today){ lastday = _today; positions.push(data.last[i][0]); } } } } return positions; //chart.xAxis[0].update ({labels: { step : xlabelStep }}); }, } ], yAxis: [ { title: { useHTML: false, text: "", }, labels:{ enabled : y_visible, align:'right', x: 38, y: 0, formatter: function () { return this.value; }, style: {color: "#000"} }, opposite: true, tickAmount : 4, showFirstLabel: true, showLastLabel: true, gridLineDashStyle: 'Solid', gridLineWidth: 1, // offset:0, tickPixelInterval:40, tickAmount : 4, showFirstLabel: true, showLastLabel: true, max: max, min: min, plotLines: [{ value: lastc, width: 2, color: this.colors["line2"], dashStyle: 'Solid' }] } ], navigator : { enabled : false, }, scrollbar : { enabled : false }, series : [ { data : last, useHTML: true, color: this.colors["line1"], lineWidth: 1, type: 'area', dataGrouping: { enabled: false, } } ], exporting: { enabled: false } }; }, redraw: function(){ var chart = this.chart; var offsetx,offsety; var self = this; var offsetx = 20; var offsety = 30; }, addLegendText: function(x,y,text,i, color){ var chart = this.chart; $("#drawLegendRect"+i).remove(); $("#drawLegendText"+i).remove(); chart.renderer.rect(x, y, 25,8, 0).attr({ fill: color, 'stroke-width': 0, id : 'drawLegendRect'+i, zIndex: 5, }).add(); chart.renderer.label(text, x+30, y-8, '', '' + '', '' + '') .css({ color: color, fontSize:'15px' }) .attr({ zIndex: 5, id: 'drawLegendText'+i, }) .add(); }, drawBackground: function(){ var chart = this.chart; var offsetx,offsety; var self = this; this.redraw(); }, labels : { zh_hk :{ warrant:{ typetext : "認股證", textmsg : "認股證價格
(港元)
" }, cbbc:{ typetext : "牛熊證", textmsg : "牛熊證價格
(港元)
" }, price : "價格", turnover : "成交額", volume : "成交量", time : "時間" }, zh_cn :{ warrant:{ typetext : "认股证", textmsg : "认股证价格
(港元)
" }, cbbc:{ typetext : "牛熊证", textmsg : "牛熊证价格
(港元)
" }, price : "价格", turnover : "成交额", volume : "成交量", time : "时间" }, en_hk :{ warrant:{ typetext : "Warrants", textmsg : "Warrants Price
(HKD)
" }, cbbc:{ typetext : "CBBCs", textmsg : "CBBCs Price
(HKD)
" }, price : "Price", turnover : "Turnover", volume : "Volume", time : "Time" }, } }