每次渲染星标和结束日期时,都会使我不断显示此错误。我已经尝试过给日期格式很长的时间,但是仍然显示错误...
start: Date.UTC(2019, 02, 30), // this line is error end: Date.UTC(2019, 08, 23), // this line is error Error: <rect> attribute x: Expected length, "NaN". Error: <rect> attribute width: Expected length, "NaN". Error: <rect> attribute x: Expected length, "NaNNaN". Error: <rect> attribute width: Expected length, "NaNNaN".
我只需要渲染它,但是它表明这些开始和结束都在 格式错误或显示错误。 这是jsfiddle:Online example
var today = new Date(),
day = 1000 * 60 * 60 * 24;
var options = {
title: {
text: 'Visual Planner Chart with Navigation',
},
xAxis:
currentDateIndicator: true,
min: today - 3 * day,
max: today + 18 * day
},
yAxis: {
uniqueNames: true
},
series: [{
name: 'Visual Planner',
data: [],
dataLabels: {
enabled: true,
format: '{point.owner}'
}
}]
}
// for reference https://api.highcharts.com/gantt/
var ganttChart = Highcharts.ganttChart('container-ganttChart', options)
// call gantt chart then add series
ganttChart.series[0].addPoint({
start: Date.UTC(2019, 01, 30),
end: Date.UTC(2019, 05, 29),
name: 'crewRank',
owner: 'crewName'
})
答案 0 :(得分:1)
您应该使用getTime
方法获取毫秒,然后在计算中使用它们:
var today = new Date().getTime(),
day = 1000 * 60 * 60 * 24;
另外,更改selected
属性中的值:
rangeSelector: {
...,
selected: 1
}
实时演示: https://jsfiddle.net/BlackLabel/mbyn8k0d/
API: https://api.highcharts.com/highstock/rangeSelector.selected