I'm facing a little challenge trying to understand how the JavaScript function getDate
interacts with Highcharts datetime on xAxis.
My goal is to show two dates in the tooltip header, forming a date range like this: 1960/1/1 - 1965/1/1.
The first date is retrieved from point.key
(a unix timestamp) in my dataset, which I have figured out how to set. However, displaying the second date as {5 years plus point.key}
is where I need assistance.
Despite my limited understanding of JavaScript, I know that there is a function called getdate() which looks like this:
function getdate() {
var tt = document.getElementById('txtDate').value;
var date = new Date(tt);
var newdate = new Date(date);
newdate.setDate(newdate.getDate() + 3);
var dd = newdate.getDate();
var mm = newdate.getMonth() + 1;
var y = newdate.getFullYear();
var someFormattedDate = mm + '/' + dd + '/' + y;
document.getElementById('follow_Date').value = someFormattedDate;
}
Is it possible for me to apply this function in generating the second date for my tooltip like so?
tooltip.headerFormat: '<span style="font-size: 16px">' +
'{point.key} - {point.key + 5 years}</span><br/>';
If you want to see the issue in action, check out this fiddle.