gpt4 book ai didi

javascript - 如果日期值小于当前日期,如何更改水平条的背景颜色?

转载 作者:行者123 更新时间:2023-12-02 23:45:02 24 4
gpt4 key购买 nike

如果日期值小于当前日期,我想更改 highcharts(甘特图)中水平条的背景颜色?请看图: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'
})

最佳答案

假设您按照上面的代码指定了 starttoday,这似乎可以工作(用它替换最后一部分,其他代码未修改):

    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'
}

颜色为红色或蓝色,具体取决于当前日期值

关于javascript - 如果日期值小于当前日期,如何更改水平条的背景颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55892459/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com