Skip to content

Commit

Permalink
Merge pull request #1065 from Codeinwp/fix/charts-refresh
Browse files Browse the repository at this point in the history
Fix multiple charts facade and small google fix
  • Loading branch information
vytisbulkevicius authored Dec 18, 2023
2 parents 8722e1b + 8a0dfcb commit 7cd7b83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
25 changes: 8 additions & 17 deletions js/render-facade.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* global jQuery */
var vizClipboard1=null;
(function($, visualizer){

function initActionsButtons(v) {
if($('a.visualizer-chart-shortcode').length > 0 && vizClipboard1 === null) {
vizClipboard1 = new ClipboardJS('a.visualizer-chart-shortcode'); // jshint ignore:line
Expand Down Expand Up @@ -107,20 +107,10 @@ var vizClipboard1=null;
registerDefaultActions();
});

// Refresh charts if chart not generated.
function refreshEachCharts() {
if ( 'object' === typeof window.fusionAnimationsVars ) {
return;
}
setTimeout( function() {
displayChartsOnFrontEnd();
}, 100 );
}

function initChartDisplay() {
if(visualizer.is_front == true){ // jshint ignore:line
displayChartsOnFrontEnd();
}else{
} else {
showChart();
}
}
Expand All @@ -138,14 +128,15 @@ var vizClipboard1=null;
}

function displayChartsOnFrontEnd() {
// display all charts that are NOT to be lazy-loaded.
$( 'div.viz-facade-loaded:not(.visualizer-lazy):not(.visualizer-cw-error):empty' ).removeClass( 'viz-facade-loaded' );
$('div.visualizer-front:not(.visualizer-lazy):not(.viz-facade-loaded)').each(function(index, element){

$('div.visualizer-front:not(.viz-facade-loaded):not(.visualizer-lazy):not(.visualizer-cw-error):empty').each(function(index, element){
if ( $(element).is(':visible') ) {
var id = $(element).addClass('viz-facade-loaded').attr('id');
showChart(id);
setTimeout(function(){
// Add a short delay between each chart to avoid overloading the browser event loop.
showChart(id);
}, ( index + 1 ) * 100);
}
refreshEachCharts();
});

// interate through all charts that are to be lazy-loaded and observe each one.
Expand Down
9 changes: 9 additions & 0 deletions js/render-google.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,18 @@ var isResizeRequest = false;
var rendered_charts = [];

function renderChart(id) {

if ( ! all_charts || 0 === Object.keys( all_charts ).length ) {
return;
}

var chart = all_charts[id];
var hasAnnotation = false;

if ( ! chart ) {
return;
}

// re-render the chart only if it doesn't have annotations and it is on the front-end
// this is to prevent the chart from showing "All series on a given axis must be of the same data type" during resize.
// remember, some charts do not support annotations so they should not be included in this.
Expand Down

0 comments on commit 7cd7b83

Please sign in to comment.