highchar的x轴数据自动生成

来源:互联网 发布:centos rpm package 编辑:程序博客网 时间:2024/06/04 17:53
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;}


0 0
原创粉丝点击