Reputation: 57
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/
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'
})
Upvotes: 0
Views: 248
Reputation: 2652
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):
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
Upvotes: 1