逝夕诚

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::
highchars的x轴是可以根据数据自动生成的,不过数据类型就和以前不一样了
管网详细的例子:http://www.hcharts.cn/test/index.php?from=demo&p=16


其中x轴可以自定义格式
xAxis: {
    type: 'datetime',
    labels: {  
        formatter: function() {
        	//自定义显示格式
        	return (new Date(this.value)).Format("yyyy-MM-dd"); 
        }  
    }
},




最后选中的点的显示
tooltip: {
	enabled: true,
	formatter: function() {
		return '<b>'+ this.series.name +'</b><br/>'+(new Date(this.x)).Format("yyyy-MM-dd") +': '+ this.y +'';
	}
},




这是date加上Format的方法
Date.prototype.Format = function (fmt) { //author: meizz 
    var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "h+": this.getHours(), //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}


posted on 2016-07-05 14:24  逝夕诚  阅读(137)  评论(0)    收藏  举报