android时间轴折线图,不规律时间轴平移缩放折线图 | JShare

本文介绍了如何使用Highcharts库创建不规律时间轴的平移缩放折线图,展示了如何实现图表的动态交互功能,包括监听图表区域选择事件以及动态修改x轴的刻度间隔值。通过示例代码展示了数据可视化中动态更新图表细节的方法。
摘要由CSDN通过智能技术生成

不规律时间轴平移缩放折线图 | JShare

var chart = null;

var OldInterval = 3;

$(function () {

Highcharts.setOptions({

lang: {

resetZoom: "返回",

resetZoomTitle: "回到初始状态"

}

});

$('#container').highcharts({

chart: {

zoomType: 'x',

panning: true,

panKey: 'ctrl',

events: {

//监听图表区域选择事件

selection: function () {

//动态修改

//DynamicChangeTickInterval(1);

}

}

},

title: {

text: null

},

xAxis: {

type: 'datetime',

labels: {

formatter :function() {

console.log(this);

return Highcharts.dateFormat(this.isFirst?'%Y-%m-%d %H:%M:%S':'%H:%M:%S', this.value);

}

}

},

yAxis: [{

title: {

text: 'Users Over Time'

},

},{

title: {

text: 'Hits Over Time'

},

opposite: true

}],

// 数据提示框日期格式化的方法:

tooltip: {

shared: true,

valueSuffix: '',

borderWidth: 1,

borderColor: '#999',

crosshairs: {

width: 1,

color: '#cccccc'

},

formatter: function() {

var s = '' + Highcharts.dateFormat('%Y/%m/%d %H:%M:%S', this.x) + '';

$.each(this.points, function () {

s += '

' + this.series.name + ': ' +this.y+'';

});

return s;

}

},

plotOptions: {

area: {

lineWidth: 1,

fillOpacity: 0.3,

marker: {

lineWidth: 1,

lineColor: '#ffffff',

symbol: 'circle'

}

}

},

legend: {

itemStyle: {

"color": "#000000",

"fontFamily": "微软雅黑"

}

},

series: [{

type: 'line',

name: 'Users',

pointInterval: 1000,

pointStart: Date.UTC(2016, 0, 1),

marker: {

enabled: false

},

data: [

0.8446, 0.8445, 0.8444, 0.8451, 0.8418, 0.8264, 0.8258, 0.8232, 0.8233, 0.8258,

0.8283, 0.8278, 0.8256, 0.8292, 0.8239, 0.8239, 0.8245, 0.8265, 0.8261, 0.8269,

0.8273, 0.8244, 0.8244, 0.8172, 0.8139, 0.8146, 0.8164, 0.82, 0.8269, 0.8269

]

},{

type: 'line',

yAxis:1,

name: 'Hits',

pointInterval: 1000,

pointStart: Date.UTC(2016, 0, 1),

marker: {

enabled: false

},

data: [

0.7869, 0.7837, 0.7827, 0.7825, 0.7779, 0.7791, 0.779, 0.7787, 0.78, 0.7807,

0.7803, 0.7817, 0.7799, 0.7799, 0.7795, 0.7801, 0.7765, 0.7725, 0.7683, 0.7641,

0.7639, 0.7616, 0.7608, 0.759, 0.7582, 0.7539, 0.75, 0.75, 0.7507, 0.7505

]

}]

});

//ExtendHighcharts();

});

//动态修改xAxis的刻度间隔值

function DynamicChangeTickInterval(interval) {

chart.xAxis[0].update({

tickInterval: interval

});

}

//扩展或者重写Highcharts图表组件的方法

function ExtendHighcharts() {

Highcharts.extend(Highcharts.Chart.prototype, { zoomOut: function () {

//还原图表X轴的间隔

DynamicChangeTickInterval(OldInterval);

//还原图表初始状态

this.zoom();

}

});

}

{"resource":"1,3","options":null,"code":{"code":"JYEya1","name":"不规律时间轴平移缩放折线图","version":0,"doctype":0,"description":"","meta":null,"newGroup":1297,"group":{"id":1297,"name":"highcharts","code":"jamky"}}}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值