Reputation: 13
I have simple gannt anychart diagram. Is it possible to get timestamp in tooltip when cursor is over the row, but no any data for this timestamp?
var treeData = anychart.data.tree(data, "as-tree");
var chart = anychart.ganttResource();
chart.data(treeData);
chart.container("container").draw();
chart.fitAll();
var tlTooltip = chart.getTimeline().tooltip();
tlTooltip.width(300);
tlTooltip.titleFormat(function () {
return 'Schedule for ' + this.name <- how to get timestamp here if cursor is over the row?
});
This code works only if there are records over cursor, overwise this.period returns undefined
tlTooltip.format(function () {
var hoveredPeriod = this.period;
console.log(hoveredPeriod );
}
Upvotes: 0
Views: 20
Reputation: 13
Opps, find out:
tlTooltip.titleFormat(function () {
var hoverDate = (this.hoverDateTime);
var dt = new Date(Number(hoverDate))
return 'Schedule for ' + this.name + '\n on ' + dt.getUTCHours() + ':' + String(dt.getUTCMinutes()).padStart(2, "0")
});
Upvotes: 0