var usPieChart = {
chart : null,
container : "",
isHSI: false,
isHome: false,
wtype : null,
type : null,
ctype : null,
fromdate : null,
todate : null,
mode : "desktop",
container : "",
vol_unit: "",
title: "",
init : function(type){
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"];
$.getJSON('/?q=/'+lang+'/data/chart/usPieChart/type/'+type, function(_data) {
var data = self.decode(_data);
$((self.container=='')?'#usPieChartContainer':'#'+self.container).highcharts('StockChart',self.getJSON(data), function (chart){
self.chart = chart;
self.drawBackground();
$("#intro_"+type+" .stime").html(_data.stime);
$("#intro_"+type+" .ref").html(_data.ref);
});
});
},
decode : function(_data){
return _data.mainData;
},
getJSON : function(data){
var self = this;
return {
chart : {
// marginBottom: 50,
// marginLeft: 50,
// marginRight: 50,
// marginTop: 50,
height: 300,
type: 'pie',
events: {
redraw: function(event) {
self.redraw();
}
}
},
accessibility: {
point: {
valueSuffix: '%'
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: false,
format: '{point.name}'
},
}
},
legend: {
enabled: true,
align: 'right',
layout: 'vertical',
verticalAlign: 'top',
symbolHeight: 12,
symbolWidth: 12,
symbolRadius: 0,
x: 0,
y: 0
},
tooltip: {
pointFormat: '{point.percentage:.1f}%'
},
rangeSelector : {
inputEnabled:false,
enabled: false
},
navigator : {
enabled : false,
// top:540
},
scrollbar : {
enabled : false
},
series : [{
name: 'pie',
colorByPoint: true,
showInLegend: true,
data: data
}],
exporting: {
enabled: false
}
};
},
redraw: function(){
var chart = this.chart;
var offsetx,offsety;
var self = this;
var offsetx = 0;
var offsety = 10;
},
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 :{
ytitle1: "使用額度",
},
zh_cn :{
rmb: '人民币'
},
en_hk :{
rmb: ' in RMB'
},
},
}