var ahdataChart = { chart : null, container : "", isHSI: false, wtype : null, type : null, ctype : null, fromdate : null, todate : null, mode : "desktop", container : "", init : function(year){ var self = this; //self.mode = (window.innerWidth<991)?"mobile":"desktop"; self.labels["edu"] = 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"]; $.getJSON('/?q=/'+lang+'/data/chart/ahdataChart/year/'+year, function(_data) { var data = self.decode(_data); var date = self.decode_date(_data); self.fromdate = date[0]; self.todate = date[1]; var data = self.decode(_data); $('#ahdataChartContainer').highcharts('StockChart',self.getJSON(data), function (chart){ self.chart = chart; self.drawBackground(); }); }); }, decode : function(_data){ return _data.mainData; }, decode_date : function(_data){ return _data.date; }, colors : {line1 : "#88abd5"}, margin : {mobile: 70, desktop: 80}, chartheight : {mobile: 218, desktop: 262}, getJSON : function(data){ var last = data.last; var max = data.max; var min = data.min; var self = this; return { chart : { marginBottom: 50, marginRight: 50, marginTop: 20, spacingTop: -5, height: 400, 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 += '
'+ this.points[0].y.toLocaleString() +self.labels[lang].point+' '; return _html; } }, rangeSelector : { inputEnabled:false, enabled: false }, xAxis:{ type: 'datetime', labels: { formatter: function () { return Highcharts.dateFormat('%m/%Y', this.value); } }, }, yAxis: [ { title: { useHTML: false, text: "", }, labels:{ align:'right', x: 40, //y: 15, y: 5, formatter: function () { return (this.isFirst)?"":(this.value).toFixed(2); }, style: {color: "#88abd5"} }, opposite: true, tickAmount : 6, showLastLabel: true, gridLineDashStyle: 'Solid', max: max, min: min }], navigator : { enabled : false, // top:540 }, scrollbar : { enabled : false }, series : [{ data : last, color : this.colors["line1"], }], exporting: { enabled: false } }; }, redraw: function(){ var chart = this.chart; var offsetx,offsety; var self = this; var offsetx = 60; 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:'12px' }) .attr({ zIndex: 5, id: 'drawLegendText'+i, }) .add(); }, drawBackground: function(){ var chart = this.chart; var offsetx,offsety; var self = this; this.redraw(); }, labels : { zh_hk :{ point: "點" }, zh_cn :{ point: "点" }, en_hk :{ point: "point" }, }, }