javascript - Google Charts chart area out of bounds -


i have google charts annotation chart 1 below inside tabs. problem is, it's not being drawn if it's little out of bounds somehow.

i assume it's related chart being drawn when page loads , when click on tab, size of chart's container changes. i'm not sure how fix that. hint appreciated.

this chart:

google.load('visualization', '1', { 'packages': ['annotationchart'] }); google.setonloadcallback(drawchart);  function drawchart() {     var data = new google.visualization.datatable();     data.addcolumn('date', 'date');     data.addcolumn('number', 'kepler-22b mission');     data.addcolumn('string', 'kepler title');     data.addcolumn('string', 'kepler text');     data.addcolumn('number', 'gliese 163 mission');     data.addcolumn('string', 'gliese title');     data.addcolumn('string', 'gliese text');     data.addrows([         [             new date(2314, 2, 15), 12400, undefined, undefined,             10645, undefined, undefined         ],         [             new date(2314, 2, 16), 24045, 'lalibertines', 'first encounter',             12374, undefined, undefined         ],         [             new date(2314, 2, 17), 35022, 'lalibertines', 'they tall',             15766, 'gallantors', 'first encounter'         ],         [             new date(2314, 2, 18), 12284, 'lalibertines', 'attack on our crew!',             34334, 'gallantors', 'statement of shared principles'         ],         [             new date(2314, 2, 19), 8476, 'lalibertines', 'heavy casualties',             66467, 'gallantors', 'mysteries revealed'         ],         [             new date(2314, 2, 20), 0, 'lalibertines', 'all crew lost',             79463, 'gallantors', 'omniscience achieved'         ]     ]);      var options = {         displayannotations: true,         'height': 500,         'width': 900,     };      var chart = new google.visualization.annotationchart(document.getelementbyid('chart_div'));     var chart2 = new google.visualization.annotationchart(document.getelementbyid('chart_div2'));     var chart3 = new google.visualization.annotationchart(document.getelementbyid('chart_div3'));      chart.draw(data, options);     chart2.draw(data, options);     chart3.draw(data, options); } 

and 1 of tabs:

<ul class="nav nav-tabs" data-tabs="tabs"> @foreach (var item in model) {     <li id="wellnav" class="@(item.well == 1 ? "active" : "")"><a id="id2"                                                                   href="#tab-@item.well"                                                                    data-toggle="tab"">@item.well</a></li> } 

<div id="tabs" class="tab-content">     <div id="tab-1" class="tab-pane">     <div id="chart_div"></div>        </div> 

update:

here's example on fiddle on i'm seeing. notice how chart in tab 2 has broken dimensions or, @ least, doesn't right. fiddle borrowed , modified this post.

http://jsfiddle.net/06rwpft8/1/

it seem chart isn't rendered on hidden objects. perhaps there better ways handle directly in google chart settings, solution draw actual chart when tab shown. example, call draw once if tab clicked:

$('a[title=content_2]').one('click',function(){     chart2.draw(data, options); }); 

fiddle


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -