Google Gantt Chart

756 views
Skip to first unread message

vincent chinapiel

unread,
Oct 1, 2017, 2:01:58 PM10/1/17
to Google Visualization API
1. Do we have the option auto-height and auto-width in Google Gantt Chart?

2. Do we also have the option of scroll bar on Google Gantt Chart?

Paulo Hernandez

unread,
Apr 19, 2018, 4:46:01 PM4/19/18
to Google Visualization API
Hello my friend,
Did you get any response to this problem?

Sean Larson

unread,
Apr 20, 2018, 4:14:44 PM4/20/18
to Google Visualization API
I have not used this chart yet, but if it behaves likes the others then:
#1, set your options variable as such and make sure the target DIV is styled properly:
options = {
                    width
: '100%',
                    height
: '100%',

#2, Kind of. If you simply set the width to 100% as I suggested above, the engine will cram the entire chart into the view width. This can cause some datasets to look very cramped. 

To work around this, we need to understand that the GC engine is drawing an SVG which requires a known width in pixels. Setting width to 100% is just passing the viewwidth as pixels.

So...to get a scrollbar we should determine the minimum size we want something to be. For example, say I do not want bars in my barchart any smaller than 50px. Well, then I need to fetch how many bars my dataset has and the current viewwidth, and do some division. If the value is less than 50, I need to multiply the # of columns by my minimum width, and set this as the CHART width. Then set the target div width to 100vw and with css style "overflow-x:auto". This mostly works, but you cannot "grab" the chart and drag it left or right, so I used some draggable plugin.

This should work for the gantt chart, but it is not responsive to filters (if those exist for gantt), or at least I have not yet found a way to intercept the filter event and recalculate what the width should be based on the filtered dataset.

Hope this helps.


Paulo Hernandez

unread,
Apr 23, 2018, 11:05:37 AM4/23/18
to Google Visualization API
Thank you very much for your help, it has helped me a lot, although I still have problems with being able to leave the static months or days in sight. But thanks to you I already have an advance.

regards
Reply all
Reply to author
Forward
0 new messages