highstock中文动态指数感谢网络上的某帅哥


发布时间:2014/5/13 22:41:51  次浏览  作者:admin

<html>  
<head>  
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">  
<title>title</title>  

</head>  
  <body>
   <div id="container" style="height: 263px; min-width: 317px; width:317px;"></div>
  </body>
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
  <script src="../../js/highstock.js"></script>


  <script type="text/javascript">
  var usdeur = [
[Date.UTC(2013,1,1),103.1],
[Date.UTC(2013,2,1),95.1],
[Date.UTC(2013,3,1),105.1],
[Date.UTC(2013,4,1),115.6],
[Date.UTC(2013,5,1),116.1],
[Date.UTC(2013,6,1),125.2],
[Date.UTC(2013,7,1),136.1],
[Date.UTC(2013,8,1),132.8],
[Date.UTC(2013,9,1),125.2],
[Date.UTC(2013,10,1),115.1],
[Date.UTC(2013,11,1),113.3],
[Date.UTC(2013,12,1),116.1],
[Date.UTC(2014,1,1),119.2],
[Date.UTC(2014,2,1),121.6],
[Date.UTC(2014,3,1),124.2],
[Date.UTC(2014,4,1),124.8],
[Date.UTC(2014,5,1),136.2]

];
$(function() {
	
	var chart = new Highcharts.StockChart({
	    chart: {
	        renderTo: 'container'//指向的div的id属性
	    },
	    exporting: {  
            enabled: false //是否能导出趋势图图片
        }, 
		//title : {
		//		text : '中国野生菌(南华)指数'//图表标题
		//	},
	    xAxis: {
	    	tickPixelInterval: 200,//x轴上的间隔
		//	title :{
		//		text:"title"
		//	},
			type: 'datetime', //定义x轴上日期的显示格式
			labels: {
			formatter: function() {
				var vDate=new Date(this.value);
				//alert(this.value);
				return vDate.getFullYear()+"-"+(vDate.getMonth()+1)+"-"+vDate.getDate();
			},
			align: 'center'
		}
	    },
	    yAxis : {  
                  
              //title: {  
              //    text: 'Rate'  //y轴上的标题
              //}  
         },  
		tooltip: {
            xDateFormat: '%Y-%m-%d, %A'//鼠标移动到趋势线上时显示的日期格式
        },
	    rangeSelector: {
			inputEnabled:false,//禁用日期选择框
			buttons: [{//定义一组buttons,下标从0开始
			type: 'week',
			count: 1,
			text: '周'
		},{
			type: 'month',
			count: 1,
			text: '月'
		//}, {
		//	type: 'month',
		//	count: 3,
		//	text: '3m'
		//}, {
		//	type: 'month',
		//	count: 6,
		//	text: '6m'
		//}, {
		//	type: 'ytd',
		//	text: 'YTD'
		}, {
			type: 'year',
			count: 1,
			text: '年'
		}, {
			type: 'all',
			text: 'All'
		}],
			selected: 3//表示以上定义button的index,从0开始
	    },
	    
	    series: [{
	        name: '野生菌(南华指数)',//鼠标移到趋势线上时显示的属性名
	        data: usdeur//属性值
			//marker : {
			//		enabled : true,
			//		radius : 3
			//	},
			//shadow : true
	    }]
	});
});

  </script>
</html >