$(document).ready(function () {
    var chart;
    $(".rate").click(function () {
        var adata = [];
	var rel = $(this).attr("rel");
        adata = $(this).attr("title").split("-");
	var link = "tenrate/charty";
	
        $.post(link, { id: adata[0]}, function (jdata) {
          chart = new Highcharts.Chart({
	  chart: {
		renderTo: 'container',
		defaultSeriesType: 'column'
	  },
	  title: {
		text: adata[0] + '-' + adata[1]
	  },
	  xAxis: {
		categories: jdata[0]
	  },
	  yAxis: {
		min: 0,
		title: {
			text: '元'
		},
		stackLabels: {
			enabled: true,
			style: {
				fontWeight: 'bold',
				color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
			}
		}
	  },
	  legend: {
		align: 'right',
		x: -100,
		verticalAlign: 'top',
		y: 20,
		floating: true,
		backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
		borderColor: '#CCC',
		borderWidth: 1,
		shadow: false
	  },
	  tooltip: {
		formatter: function() {
			return '<b>'+ this.x +'</b><br/>'+
			this.series.name +': '+ this.y +'<br/>'+
			'合計: '+ this.point.stackTotal;
		}
	  },
	  plotOptions: {
		column: {
			stacking: 'normal',
			dataLabels: {
				enabled: true,
				color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white'
			}
		}
	  },
	  series: [{
		name: '配股',
                data: jdata[2]
		}, {
		name: '配息',
		data: jdata[1]
	  }]
	});

        }, "json");
        $(this).colorbox({ width: "80%", inline: true, href: "#container" });
    });
});


