[英]How can I change the background color of horizontal bar if date value is less than to current date?
I want to change the background color of horizontal bar in highcharts(gantt chart) if the date value is less than to current date? 如果日期值小于当前日期,我想更改高图(甘特图)中水平条的背景颜色吗? Please take a look on the picture: https://ibb.co/3MNqJJy and this is the jsfiddle: https://jsfiddle.net/57n1cjyr/ 请看图片: https ://ibb.co/3MNqJJy,这是jsfiddle: https ://jsfiddle.net/57n1cjyr/
var today = new Date().getTime(),
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}'
}
}]
}
var ganttChart = Highcharts.ganttChart('container-ganttChart', options)
ganttChart.series[0].addPoint({
start: Date.UTC(2019, 01, 30),
end: Date.UTC(2019, 03, 01),
name: 'crewRank',
owner: 'crewName'
})
Assuming you have start
and today
specified as in the code above, this seems to work (replace the last part with it, the other code is unmodified): 假设您已经按照上面的代码指定了start
和today
,似乎可以正常工作(用最后一部分代替它,其他代码未修改):
var startDate=Date.UTC(2019, 01, 30)
// call gantt chart then add series
ganttChart.series[0].addPoint({
start: startDate,
end: Date.UTC(2019, 03, 01),
name: 'crewRank',
owner: 'crewName',
color: new Date(startDate).getTime() < today ? 'red' :'blue'
}
The color is red or blue depending on the current date value 颜色是红色还是蓝色,具体取决于当前日期值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.