how can I fix 'Error: <rect> attribute x: Expected length, "NaNNaN"
how can I fix 'Error: <rect> attribute x: Expected length, "NaNNaN"
它让我每次渲染星号和结束日期时都显示此错误。我已经尝试提供长日期格式,但仍然显示错误...
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'
})
您应该使用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
它让我每次渲染星号和结束日期时都显示此错误。我已经尝试提供长日期格式,但仍然显示错误...
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'
})
您应该使用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