Highchart: x轴随机添加额外日期
Highchart : xaxis Adding extra Dates randomly
我有两个堆叠的列图。
都包含非常相似的数据,列数相同。
所有位置
Location 3 jsfield
两者具有完全相同的初始化代码,数据是它们之间唯一的区别。
chart: { renderTo:'hcweeklySnapshotLoc_container', animation: { animation: true }, defaultSeriesType: 'column', height: 500, marginBottom: 140, zoomType: 'x' },
credits: { enabled: false },
plotOptions: { column: { dataLabels: { enabled: true }, stacking: 'normal' }, line: { lineWidth: 1, marker: { enabled: false, states: { hover: { enabled: true } } } }, series: { pointInterval: 7 }, spline: { lineWidth: 3, marker: { enabled: false, states: { hover: { enabled: true } } } } },
title: { text: 'Location 3', x: -20 },
tooltip: { formatter: function() { if(this.series.name == 'Target'|| this.series.name == 'Stretch' || this.series.name == 'Failure') { return '<b>'+ this.series.name +'</b><br/>' + Highcharts.dateFormat('%e %B %Y', this.x) +': <b>'+ this.y + '</b>' } else { return '<b>'+ this.series.name +'</b>' +'<br/>' + 'Week Ending :' + Highcharts.dateFormat('%e %B %Y', this.x) +': '+ this.y +'<br/>' + 'Total: '+ Math.round(this.point.stackTotal*Math.pow(10,2))/Math.pow(10,2);} } },
xAxis: { dateTimeLabelFormats: { month: '%b %Y' }, minRange: 86400000, startOfWeek: 5, tickInterval: 604800000, tickmarkPlacement: 'on', title: { text: 'Week ending' }, type: 'datetime' },
yAxis: { allowDecimals: false, min: 0, title: { text: 'Number of People' } }
其他位置(位置1和位置2)也面临与所有位置图相同的问题。
我的问题是,所有位置图显示一个额外的日期刻度在结束,而位置3图不是。这是Highcharts中的一些bug,还是我的数据有问题。我使用MVC4/Razor使用Highchart生成高图。净
发生这种情况的原因是因为您的序列并不都是按升序排列的。你俩的星盘也是如此。"所有地点"看起来更糟糕的原因是,它对如何渲染图表的猜测不同。如果你把你的时间序列按时间顺序排列,你应该很好。
代码:{
data: [
[Date.parse('05/31/2013 00:00:00'), 1],
[Date.parse('03/15/2013 00:00:00'), 3],
[Date.parse('05/03/2013 00:00:00'), 2],
[Date.parse('04/26/2013 00:00:00'), 3],
[Date.parse('03/29/2013 00:00:00'), 2],
[Date.parse('04/05/2013 00:00:00'), 1],
[Date.parse('03/22/2013 00:00:00'), 4],
[Date.parse('04/19/2013 00:00:00'), 6],
[Date.parse('05/17/2013 00:00:00'), 4],
[Date.parse('04/12/2013 00:00:00'), 1],
[Date.parse('05/24/2013 00:00:00'), 4],
[Date.parse('05/10/2013 00:00:00'), 1]
],
name: 'Loc3',
type: 'column',
color: '#003E69',
lineWidth: 1,
pointInterval: 7
}
时间代码:
{
data: [
[Date.parse('03/15/2013 00:00:00'), 3],
[Date.parse('03/22/2013 00:00:00'), 4],
[Date.parse('03/29/2013 00:00:00'), 2],
[Date.parse('04/05/2013 00:00:00'), 1],
[Date.parse('04/12/2013 00:00:00'), 1],
[Date.parse('04/19/2013 00:00:00'), 6],
[Date.parse('04/26/2013 00:00:00'), 3],
[Date.parse('05/03/2013 00:00:00'), 2],
[Date.parse('05/10/2013 00:00:00'), 1],
[Date.parse('05/17/2013 00:00:00'), 4],
[Date.parse('05/24/2013 00:00:00'), 4],
[Date.parse('05/31/2013 00:00:00'), 1]
],
name: 'Loc3',
type: 'column',
color: '#003E69',
lineWidth: 1,
pointInterval: 7
}
相关文章:
- 将日期添加到日期输入字段Angular
- 使用javascript将两个输入的日期添加在一起
- 在循环中为日期添加天数,javascript
- 使用奇怪的控制台日志结果向输入日期添加天数
- jQuery将日期添加到输入中,但仅当它's是空的
- 在 javascript 中为日期添加时间
- 在 Java 脚本中向日期添加变量编号
- 将日期添加到日期以使明天成为当前日期 - Javascript
- 使用AngularJS将当前日期添加到帖子中
- 如何使用 JavaScript 从当前日期添加一年
- 使用Greasemonkey为页面上的日期添加粗体标签
- Javascript为未来日期添加时间
- 是否有一个内置函数可以将创建日期添加到couchDB中的文档中
- 使用jquery或Javascript向选定日期添加天数
- 使用JavaScript为日期添加1年
- 将日期添加到用php和javascript编写的时钟和日期脚本中
- 将开始日期和结束日期添加为高图中的X轴标签
- 使用jquery日期选择器向日期添加自定义属性
- 在不更改GMT时间的情况下为日期添加天数
- Javascript日期添加