| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | |
| 5 | 5 | // this will store the images for each chart rendered. |
| 6 | 6 | var __visualizer_chart_images = []; |
| 7 | 7 | var chartWrapperError = []; |
| 8 | +var isResizeRequest = false; | |
| 8 | 9 | |
| 9 | 10 | (function($) { |
| 10 | 11 | var gv; |
| 11 | 12 | var all_charts, objects; |
| @@ -12,11 +13,20 @@ | ||
| 12 | 13 | // so that we know which charts belong to our library. |
| 13 | 14 | var rendered_charts = []; |
| 14 | 15 | |
| 15 | 16 | function renderChart(id) { |
| 17 | + | |
| 18 | + if ( ! all_charts || 0 === Object.keys( all_charts ).length ) { | |
| 19 | + return; | |
| 20 | + } | |
| 21 | + | |
| 16 | 22 | var chart = all_charts[id]; |
| 17 | 23 | var hasAnnotation = false; |
| 18 | 24 | |
| 25 | + if ( ! chart ) { | |
| 26 | + return; | |
| 27 | + } | |
| 28 | + | |
| 19 | 29 | // re-render the chart only if it doesn't have annotations and it is on the front-end |
| 20 | 30 | // this is to prevent the chart from showing "All series on a given axis must be of the same data type" during resize. |
| 21 | 31 | // remember, some charts do not support annotations so they should not be included in this. |
| 22 | 32 | var no_annotation_charts = ['tabular', 'timeline', 'gauge', 'geo', 'bubble', 'candlestick']; |
| @@ -39,13 +49,14 @@ | ||
| 39 | 49 | |
| 40 | 50 | function renderSpecificChart(id, chart) { |
| 41 | 51 | var render, container, series, data, table, settings, i, j, row, date, axis, property, format, formatter; |
| 42 | 52 | |
| 43 | - if ( $('#' + id).hasClass('visualizer-chart-loaded') || ( 'canvas' !== id && $('#' + id).children( ':not(.loader)' ).length > 0 ) ) { | |
| 53 | + if( chart.library !== 'google' ) { | |
| 44 | 54 | return; |
| 45 | 55 | } |
| 46 | - | |
| 47 | - if(chart.library !== 'google'){ | |
| 56 | + | |
| 57 | + // Bail if the chart is already rendered or is being rendered. | |
| 58 | + if ( ! window.isResizeRequest && ( $('#' + id).hasClass('visualizer-chart-loaded') || ( 'canvas' !== id && $('#' + id).children( ':not(.loader, style)' ).length > 0 ) ) ) { | |
| 48 | 59 | return; |
| 49 | 60 | } |
| 50 | 61 | rendered_charts[id] = 'yes'; |
| 51 | 62 | |
| @@ -116,8 +127,13 @@ | ||
| 116 | 127 | { |
| 117 | 128 | settings['animation']['startup'] = true; |
| 118 | 129 | settings['animation']['duration'] = parseInt(settings['animation']['duration']); |
| 119 | 130 | } |
| 131 | + if ( settings['controls'] ) { | |
| 132 | + settings['controls']['ui']['allowMultiple'] = 'true' === settings['controls']['allowMultiple'] ? true : false; | |
| 133 | + settings['controls']['ui']['allowTyping'] = 'true' === settings['controls']['allowTyping'] ? true : false; | |
| 134 | + settings['controls']['ui']['showRangeValues'] = 'true' === settings['controls']['showRangeValues'] ? true : false; | |
| 135 | + } | |
| 120 | 136 | |
| 121 | 137 | // mark roles for series that have specified a role |
| 122 | 138 | // and then remove them from future processing |
| 123 | 139 | // and also adjust the indices of the series array so that |
| @@ -476,10 +492,11 @@ | ||
| 476 | 492 | |
| 477 | 493 | var resizeTimeout; |
| 478 | 494 | |
| 479 | 495 | $(document).ready(function() { |
| 480 | - $(window).resize(function() { | |
| 496 | + $(window).resize(function(e) { | |
| 481 | 497 | clearTimeout(resizeTimeout); |
| 498 | + window.isResizeRequest = 'undefined' !== typeof e.originalEvent ? true : false; | |
| 482 | 499 | resizeTimeout = setTimeout(render, 100); |
| 483 | 500 | }); |
| 484 | 501 | |
| 485 | 502 | resizeHiddenContainers(true); |