如果日期值小于当前日期,如何更改水平条的背景颜色?
How can I change the background color of horizontal bar if date value is less than to current date?
如果日期值小于当前日期,我想更改highcharts(甘特图)中水平条的背景颜色?请看图:https://ibb.co/3MNqJJy and this is the 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'
})
假设您在上面的代码中指定了 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'
}
颜色为红色或蓝色,具体取决于当前日期值
如果日期值小于当前日期,我想更改highcharts(甘特图)中水平条的背景颜色?请看图:https://ibb.co/3MNqJJy and this is the 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'
})
假设您在上面的代码中指定了 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'
}
颜色为红色或蓝色,具体取决于当前日期值