Highcharts.setOptions({lang :{ rangeSelectorZoom : "", /*rangeSelectorFrom : "", rangeSelectorTo : "",*/ noData : "沒有相關資料", }}); var uIntradayChart = { chart : null, container : "", period : "intraday", chartType : "line", init : function(code, type){ var self = this; if (type == "intraday" || type == "daily" || type == "weekly" || type == "monthly"){ self.period = type; } if(type == "candle"){ self.chartType = type; } var urlstring; if(type != "candle" && self.period != "intraday"){ urlstring = '/?q=/'+lang+'/data/chart/uIntradayChart/code/'+code+'/period/'+self.period; }else{ urlstring = '/?q=/'+lang+'/data/chart/OHLC/code/'+code+'/type/'+type; } $.getJSON(urlstring, function(_data) { var data = self.decode(_data); // $('#uIntradayChartContainer').highcharts('StockChart',self.getJSON(data), function (chart){ $((self.container=='')?'#uIntradayChartContainer':'#'+self.container).highcharts('StockChart', self.getJSON(data), function(chart){ self.chart = chart; self.drawBackground(); //self.chart.tooltip.refresh(self.chart.series[1].points[1]); }); }); }, decode : function(_data){ return _data.mainData; }, colors : {line1 : "#7EDBD5", bar1 : "#FED03A", text:"#C6C6C6", grid:"#7D7D7D", grid2:"#BFBFBF"}, getJSON : function(data){ var close = []; var os = []; var osp = []; var turnover = []; var self = this; var chart = this.chart; if(data===null) { var data=[]; } for (i = 0; i < data.length; i++) { if(self.chartType != "candle" && self.period!="intraday"){ close.push([data[i][0], data[i][1]]); turnover.push([data[i][0] , data[i][2]]); }else{ if(self.chartType != "candle") { close.push([data[i][0], data[i][4]]); turnover.push([data[i][0] , data[i][6]]); }else{ close.push([data[i][0], data[i][1], data[i][2], data[i][3], data[i][4]]); turnover.push([data[i][0] , data[i][6]]); } } } return { chart : { marginLeft: 60, marginRight: 5, // marginBottom: 5, marginBottom: 20, spacingTop: 50, events: { redraw: function(event) { self.redraw(); } } }, plotOptions: { line: { events: { legendItemClick: function () { return false; } } } }, /*tooltip: { useHTML: true, formatter: function() { var _html = '
' + Highcharts.dateFormat('%Y-%m-%d', this.x) + ''; _html += '
'+self.labels[lang].hTitle1+': ' + this.points[0].y + ''; return _html; } },*/ /*tooltip: { backgroundColor: 'none', borderWidth: 0, shadow: false, useHTML: true, padding: 0, formatter: function() { var html = ''+(this.points[0].y.toFixed(2))+""; //console.log(this.points[0]); //if (!isNaN(this.points[1].y)){ if(undefined !=this.points[1]){ html += '                                              '; html += ''+(this.points[1].y.toFixed(2)/100)+""; } //html += '                                  '; //html += ''+(Highcharts.dateFormat('%H:%M:%S', this.x))+""; return "
"+html+"
"; }, positioner: function () { return { x: 78, y: 2 }; // return { x: chart.chartWidth/2, y: 2 }; } }*/ tooltip: { useHTML: true, formatter: function() { var _html = ""; //if(typeof this.points[2] != "undefined"){ _html = '
' + Highcharts.dateFormat('%Y/%m/%d', this.x) + ''; _html += '
'+ this.points[0].series.name +' ' + this.points[0].y.toFixed(2) + ''; _html += '
' + this.points[1].series.name + ' ' + (this.points[1].y.toFixed(2)/1000); + "
"; //} if(_html == ""){ return false; } return _html; } }, rangeSelector : { enabled : false, }, /* xAxis:{ type: 'datetime', gridLineWidth: 0, tickColor: '#00000000', labels: { formatter: function () { return Highcharts.dateFormat('%d/%m', this.value); } } }, */ xAxis:{ type: 'datetime', gridLineWidth: 0, tickColor: '#00000000', lineColor: '#00000000', labels: { //enabled: false, style: {color: self.colors["grid"]}, formatter : function() { if(self.period == "intraday"){ return Highcharts.dateFormat('%H:%M', this.value); }else{ return Highcharts.dateFormat('%m/%d', this.value); } } }, /*tickPositioner: function () { if(self.period == "intraday"){ // tickPositioner for daily var positions = []; var msec = 60*60*1000; var lastday = 0; if(close.length>=1) { close[close.length-1][0]; } for (i=0;i