javascript - Google Charts Timeline - Move DateYear to the Top of the Chart? - Stack Overflow

admin2025-04-20  0

Here is a sample of a Google Superbowl Timeline:

Is there a way to move the Date/Year to the top of the Timeline Chart?

Alternatively, are there any other Timeline Charts that would provide additional customization?

Here is a sample of a Google Superbowl Timeline:

https://developers.google./chart/interactive/docs/datesandtimes#dates-and-times-using-the-date-string-representation

Is there a way to move the Date/Year to the top of the Timeline Chart?

Alternatively, are there any other Timeline Charts that would provide additional customization?

Share Improve this question asked May 19, 2016 at 16:21 WayBehindWayBehind 1,6973 gold badges41 silver badges61 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

I haven't find any Google option, but I did this with SVG transformation

https://jsfiddle/d1x5hyes/1/

function afterDraw() {
    var g = document.getElementsByTagName("svg")[0].getElementsByTagName("g")[1];
    document.getElementsByTagName("svg")[0].parentNode.style.top = '40px';
    document.getElementsByTagName("svg")[0].style.overflow = 'visible';
    var height = Number(g.getElementsByTagName("text")[0].getAttribute('y')) + 15;
    g.setAttribute('transform','translate(0,-'+height+')');
    g = null;
}

Building on @shoggs answer, here is how to move the labels to the top on a Google Gantt chart, while preserving the formatting of the rows.

let labels = document.getElementsByTagName("svg")[0].getElementsByTagName("g")[1].getElementsByTagName("text")
document.getElementsByTagName("svg")[0].style.overflow = 'visible'
for (var i=0; i < labels.length; i++) {
    labels[i].setAttribute("y", -15)                                                                                                
}
转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745106085a285297.html

最新回复(0)