Here are some of my findings on setting column widths in gviz tables. My main issue was with cells with long text that I wanted to set a min-width to reduce the vertical space taken with wrapping. The google visualization default width appears to be the width of the header text.(for a table so wide it needs to be horiz scrolled) So my very crude solution is to make the header text my min-width (ie ' ---------------------Header for Col B------------------------'). I am sure there is some more exotic way to do this, but this suits my purposes for now.
The setProperty statement (ie. data.setProperty(0,0,'style','width:400px'); does work (even though 0.0 is not the header cell), BUT only if there is adequate room in the allotted div. For example, it cannot be so large that horizontal scrolling would be needed?? It can be made smaller, but not smaller than the header text (the header text cannot be wrapped?) and no smaller than smallest string fragment in that column. [see my fiddle where I forced 'Name' column to wrap.] https://jsfiddle.net/Jay_Campbell/Lhqrj7yq/2/ On Sunday, May 7, 2017 at 7:51:06 PM UTC-4, Daniel LaLiberte wrote: > > Sorry, I forgot to mention that you will need to use css to set the width > of a column, if you can do it at all. And you will need to do it not using > any of the supported cssClassNames, since not apply to specific columns. > > I suppose it would be easier for users if we provide more direct support > for this kind of thing. > > On Sun, May 7, 2017 at 7:39 PM, Daniel LaLiberte <[email protected] > <javascript:>> wrote: > >> Hi Jay, >> >> You are setting the 0th row property, which is actually the first data >> row, not the header row. If you set some other property, such as 'color', >> you will see that the property is being set properly for the data cell, and >> you can see (in the debugger) your width setting for the element as well. >> >> But even if you could set the width of the header column (a th element), >> this is not all you need to do to set the width of an html table. There >> might be some interference with other settings for the table, and its >> containers, however. It might be that we have broken the ability to set >> the column width of a table. So, experiment with removing your 100% width >> option, or setting to a specific width, or 'auto'. >> >> Hope that helps. >> >> On Sun, May 7, 2017 at 3:38 PM, Jay OCHS < >> [email protected] <javascript:>> wrote: >> >>> >>> > -- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-visualization-api. To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/18f60311-1568-4733-86d9-62ea84c3b37a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
