码迷,mamicode.com
首页 > 其他好文 > 详细

Highcharts with all data for tooltip

时间:2015-05-18 20:17:59      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:

PHP code

	header("Content-type: text/json");

	$items = array();
        while($row = mysql_fetch_object($rs)){
		$newDT = strtotime($row->dt) * 1000;
		$pass_rate = $row->pass_rate;
		$items[$row->tester][‘name‘]=$row->tester;
		$product = $row->product;
		$PSPT = $row->PSPT;
		$lot = $row->lot;
		$wafer = $row->wafer;
		$comment = $row->comment;			
		
		// The x value is the current JavaScript time, which is the Unix time multiplied by 1000.
		$x = strtotime($row->dt) * 1000;
		$y = floatval($row->pass_rate);	
		$ret = array($x, $y);
		
		$arrDetails = array(‘PSPT‘ => $PSPT, ‘product‘ => $product, ‘lot‘ => $lot, ‘wafer‘ => $wafer, ‘comment‘ => $comment );
		$items[$row->tester][‘data‘][]=json_encode($ret);
		$items[$row->tester][‘details‘]["$x"]=json_encode($arrDetails);
	}
	print json_encode($items);

  Javascipt code:

var globalData = {}; //declare a json variable

$.getJSON(‘data_main.php‘, function(data) {					
	$.each(data, function(key,value) {
		globalData[key] = value; //update to globalData for tooltip
	});	
});	

formatter: function(){					
	var json = eval("("+globalData[this.series.name]["details"][this.x]+")");
	var tt = "<b>Tester: </b>"+this.series.name + "<br />";
	tt = tt+ "<b>PSPT: </b>"+json.PSPT + "<br />";
	tt = tt+ "<b>Product: </b>"+json.product + "<br />";
	tt = tt+ "<b>Lot: </b>"+json.lot + "<br />";
	tt = tt+ "<b>Wafer: </b>"+json.wafer + "<br />";
	tt = tt+ "<b>comment: </b>"+json.comment + "<br />";
	return tt;
}

  Result:

技术分享

Highcharts with all data for tooltip

标签:

原文地址:http://www.cnblogs.com/binglong/p/4512762.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!