Javascript 我可以用不同的年份(闰年)同步两个高图表系列吗
问题最好在下面的fiddle中描述: . 我们使用两个系列和两个X轴Javascript 我可以用不同的年份(闰年)同步两个高图表系列吗,javascript,highcharts,highstock,linechart,leap-year,Javascript,Highcharts,Highstock,Linechart,Leap Year,问题最好在下面的fiddle中描述: . 我们使用两个系列和两个X轴 xAxis: [{ type: 'datetime', min: new Date('2016/02/22').getTime(), max: new Date('2016/03/05').getTime() }, { type: 'datetime', min: new Date('2015/02/22').getTime(),
xAxis: [{
type: 'datetime',
min: new Date('2016/02/22').getTime(),
max: new Date('2016/03/05').getTime()
}, {
type: 'datetime',
min: new Date('2015/02/22').getTime(),
max: new Date('2015/03/06').getTime()
}],
我想比较每年的TIM系列,由于闰年(2016年,2月29日),它们的值不同
要求:
即使有闰年,也要在每个日期下方显示相等的日期。
在本例中,您可以看到3月1日显示在2月29日下方。对于非闰年时间序列,应该有一个间隙。即使我在3月1日添加一个空值,我也无法停止房间时间连续体
有人能帮我吗?我会这样做: 1) 使用单个x轴,起点使用当前年份(或者,无论哪一年是闰年,以确保您可以计算闰日。这里使用哪一年都无关紧要,只要是闰年。您可以使用1976年,而不影响最终结果) 2) 在闰日的日期,在没有闰日的数据系列中,插入空值 3) 使用“序列名称”表示所涉及的年份,并在工具提示(和/或需要显示日期的任何其他地方)中设置日期格式,以返回不带年份的日期 代码示例:
$('#container').highcharts({
chart: {
renderTo: 'container'
},
plotOptions: {
series: {
pointStart: Date.UTC(2016, 1, 22),
pointInterval: 24 * 3600 * 1000 // one day
}
},
tooltip: {
shared: true,
crosshairs: true,
dateTimeLabelFormats : {
day:"%b %e"
}
},
xAxis: {
type: 'datetime'
},
series: [{
name: '2015',
data: [176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, null, 71.5, 106.4, 129.2, 144.0],
},{
name:'2016',
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
}]
});
小提琴:
$('#container').highcharts({
chart: {
renderTo: 'container'
},
plotOptions: {
series: {
pointStart: Date.UTC(2016, 1, 22),
pointInterval: 24 * 3600 * 1000 // one day
}
},
tooltip: {
shared: true,
crosshairs: true,
dateTimeLabelFormats : {
day:"%b %e"
}
},
xAxis: {
type: 'datetime'
},
series: [{
name: '2015',
data: [176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, null, 71.5, 106.4, 129.2, 144.0],
},{
name:'2016',
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
}]
});