That is strange. I did realize that the Name column is the only one affected by the routine. I appreciate your assistance. I will give it another try.
On Fri, Mar 8, 2013 at 10:30 PM, asgallant <[email protected]>wrote: > That is odd then, since it works fine when I use it. It is worth pointing > out that the example code as-is only controls the width of the "Name" > column, not all columns in the table. You have to add more code to adjust > the width of the others. > > > On Friday, March 8, 2013 7:00:54 PM UTC-5, Collin Davis wrote: > >> Same as yours >> >> >> On Fri, Mar 8, 2013 at 3:49 PM, asgallant <[email protected]> wrote: >> >>> Did you use the exact code I posted, or did you adapt it to your own? >>> If you adapted it, can you post the code you are using? >>> >>> On Friday, March 8, 2013 3:52:00 PM UTC-5, Collin Davis wrote: >>>> >>>> This did not work either. >>>> >>>> On Friday, March 8, 2013 1:05:01 PM UTC-7, asgallant wrote: >>>>> >>>>> Properly, the code to modify the column width should be enclosed in a >>>>> "ready" event handler for the table, to ensure that the table is finished >>>>> drawing: >>>>> >>>>> function drawTable () { >>>>> // Create and populate the data table. >>>>> var data = google.visualization.**arrayToDa**taTable([ >>>>> ['Name', 'Height', 'Smokes'], >>>>> ['Tong Ning mu', 174, true], >>>>> ['Huang Ang fa', 523, false], >>>>> ['Teng nu', 86, true] >>>>> ]); >>>>> >>>>> // Create and draw the visualization. >>>>> var table = new google.visualization.Table(**doc** >>>>> ument.getElementById('**table'))**; >>>>> >>>>> google.visualization.events.**ad**dListener(visualization, >>>>> 'ready', function () { >>>>> // set the width of the column with the title "Name" to 100px >>>>> var title = 'Name'; >>>>> var width = '100px'; >>>>> $('.google-visualization-**table**-th:contains(' + title + >>>>> ')').css('width', width); >>>>> }); >>>>> >>>>> table.draw(data, null); >>>>> } >>>>> >>>>> google.load('visualization', '1', {packages: ['table']}); >>>>> google.setOnLoadCallback(**drawT**able); >>>>> >>>>> Try that and see if it works for you. >>>>> >>>>> On Friday, March 8, 2013 2:30:09 PM UTC-5, Collin Davis wrote: >>>>>> >>>>>> asgallant - I am attempting to use your solution below. I have >>>>>> created a table using the google visualization api as you did below, and >>>>>> then copied over the lines of jQuery code that set the column widths, >>>>>> changed the column name for the title var and the width for the width >>>>>> var. >>>>>> However, the column widths do not change. I have even copied your whole >>>>>> function into an html file and ran it. The table is created, but the >>>>>> column widths do not change when I change the width var value. >>>>>> >>>>>> What am I doing wrong? >>>>>> >>>>>> below is the script code in the <head> : >>>>>> >>>>>> <script type='text/javascript' >>>>>> src='https://www.google.com/**js**api<https://www.google.com/jsapi> >>>>>> '></script> >>>>>> <script >>>>>> src='http://www.smartcare.net/****scripts/jquery.js<http://www.smartcare.net/scripts/jquery.js>' >>>>>> type='text/javascript'></**scrip**t> >>>>>> <script type='text/javascript'> >>>>>> google.load('visualization', '1', >>>>>> {packages:['Gauge','corechart'****,'table']}); >>>>>> google.setOnLoadCallback(**drawV**isualization); >>>>>> >>>>>> function drawVisualization() { >>>>>> // Create and populate the data table. >>>>>> var data = new google.visualization.**DataTable**(); >>>>>> data.addColumn('string', 'Name'); >>>>>> data.addColumn('number', 'Height'); >>>>>> data.addColumn('boolean', 'Smokes'); >>>>>> data.addRows(3); >>>>>> data.setCell(0, 0, 'Tong Ning mu'); >>>>>> data.setCell(1, 0, 'Huang Ang fa'); >>>>>> data.setCell(2, 0, 'Teng nu'); >>>>>> data.setCell(0, 1, 174); >>>>>> data.setCell(1, 1, 523); >>>>>> data.setCell(2, 1, 86); >>>>>> data.setCell(0, 2, true); >>>>>> data.setCell(1, 2, false); >>>>>> data.setCell(2, 2, true); >>>>>> >>>>>> // Create and draw the visualization. >>>>>> visualization = new google.visualization.Table(**doc* >>>>>> *ument.getElementById('**table'))**; >>>>>> visualization.draw(data, null); >>>>>> >>>>>> // set the width of the column with the title "Name" >>>>>> to 100px >>>>>> var title = "Name"; >>>>>> var width = "500px"; >>>>>> $('.google-visualization-**table**-th:contains(' + >>>>>> title + ')').css('width', width); >>>>>> } >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> On Tuesday, July 19, 2011 11:22:42 AM UTC-6, asgallant wrote: >>>>>>> >>>>>>> The API doesn't support this, but you can hack around it using >>>>>>> jQuery: >>>>>>> >>>>>>> function drawVisualization() { >>>>>>> // Create and populate the data table. >>>>>>> var data = new google.visualization.**DataTable**(); >>>>>>> data.addColumn('string', 'Name'); >>>>>>> data.addColumn('number', 'Height'); >>>>>>> data.addColumn('boolean', 'Smokes'); >>>>>>> data.addRows(3); >>>>>>> data.setCell(0, 0, 'Tong Ning mu'); >>>>>>> data.setCell(1, 0, 'Huang Ang fa'); >>>>>>> data.setCell(2, 0, 'Teng nu'); >>>>>>> data.setCell(0, 1, 174); >>>>>>> data.setCell(1, 1, 523); >>>>>>> data.setCell(2, 1, 86); >>>>>>> data.setCell(0, 2, true); >>>>>>> data.setCell(1, 2, false); >>>>>>> data.setCell(2, 2, true); >>>>>>> >>>>>>> // Create and draw the visualization. >>>>>>> visualization = new google.visualization.Table(**doc** >>>>>>> ument.getElementById('**table'))**; >>>>>>> visualization.draw(data, null); >>>>>>> >>>>>>> // set the width of the column with the title "Name" to 100px >>>>>>> var title = "Name"; >>>>>>> var width = "100px"; >>>>>>> $('.google-visualization-**tabl**e-th:contains(' + title + >>>>>>> ')').css('width', width); >>>>>>> } >>>>>>> >>>>>>> -- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "Google Visualization API" group. >>> To unsubscribe from this topic, visit https://groups.google.com/d/** >>> topic/google-visualization-**api/1dABD84NwkE/unsubscribe?**hl=en<https://groups.google.com/d/topic/google-visualization-api/1dABD84NwkE/unsubscribe?hl=en> >>> . >>> To unsubscribe from this group and all its topics, send an email to >>> google-visualization-api+**[email protected]. >>> To post to this group, send email to google-visua...@**googlegroups.com. >>> >>> Visit this group at http://groups.google.com/** >>> group/google-visualization-**api?hl=en<http://groups.google.com/group/google-visualization-api?hl=en> >>> . >>> For more options, visit >>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>> . >>> >>> >>> >> >> >> >> -- >> Collin Davis >> Sr. Analyst >> ImagineHealth >> 801-566-6127 >> [email protected] >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "Google Visualization API" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/google-visualization-api/1dABD84NwkE/unsubscribe?hl=en > . > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To post to this group, send email to > [email protected]. > Visit this group at > http://groups.google.com/group/google-visualization-api?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Collin Davis Sr. Analyst ImagineHealth 801-566-6127 [email protected] -- 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 http://groups.google.com/group/google-visualization-api?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
