| @@ -324,10 +324,44 @@ | ||
| 324 | 324 | }); |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | $('body').on('visualizer:render:chart:start', function(event, v){ |
| 328 | + var $chart_types = ['corechart', 'geochart', 'gauge', 'table', 'timeline']; | |
| 329 | + if(v.is_front == true){ // jshint ignore:line | |
| 330 | + // check what all chart types to load. | |
| 331 | + $chart_types = []; | |
| 332 | + $.each(v.charts, function(i, c){ | |
| 333 | + var $type = c.type; | |
| 334 | + switch($type){ | |
| 335 | + case 'bar': | |
| 336 | + case 'column': | |
| 337 | + case 'line': | |
| 338 | + case 'area': | |
| 339 | + case 'stepped area': | |
| 340 | + case 'bubble': | |
| 341 | + case 'pie': | |
| 342 | + case 'donut': | |
| 343 | + case 'combo': | |
| 344 | + case 'candlestick': | |
| 345 | + case 'histogram': | |
| 346 | + case 'scatter': | |
| 347 | + $type = 'corechart'; | |
| 348 | + break; | |
| 349 | + case 'geo': | |
| 350 | + $type = 'geochart'; | |
| 351 | + break; | |
| 352 | + case 'dataTable': | |
| 353 | + $type = null; | |
| 354 | + break; | |
| 355 | + } | |
| 356 | + if($type != null){ | |
| 357 | + $chart_types.push($type); | |
| 358 | + } | |
| 359 | + }); | |
| 360 | + } | |
| 361 | + | |
| 328 | 362 | objects = {}; |
| 329 | - google.charts.load("current", {packages: ["corechart", "geochart", "gauge", "table", "timeline"], mapsApiKey: v.map_api_key, 'language' : v.language}); | |
| 363 | + google.charts.load("current", {packages: $chart_types, mapsApiKey: v.map_api_key, 'language' : v.language}); | |
| 330 | 364 | google.charts.setOnLoadCallback(function() { |
| 331 | 365 | gv = google.visualization; |
| 332 | 366 | all_charts = v.charts; |
| 333 | 367 | render(); |