From ec2391cb02297b24688004f51737b7090b19608b Mon Sep 17 00:00:00 2001 From: Bryn Ryans Date: Fri, 27 Jun 2025 16:52:44 +0000 Subject: [PATCH 1/2] fix ODF rendering issue It appears that the visualization is prematurely notifying the PDF rendering that the visualization has completed rendering. This fix adds waits to make sure all promises have finished before calling done. --- src/report_table.js | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/report_table.js b/src/report_table.js index 35e5cf8..656ebc3 100644 --- a/src/report_table.js +++ b/src/report_table.js @@ -31,7 +31,7 @@ const loadStylesheet = function (link) { document.getElementsByTagName('head')[0].appendChild(linkElement); }; -const buildReportTable = function ( +const buildReportTable = async function ( config, dataTable, updateColumnOrder, @@ -42,7 +42,7 @@ const buildReportTable = function ( const chartCentreX = bounds.x + bounds.width / 2; const chartCentreY = bounds.y + bounds.height / 2; - removeStyles().then(() => { + await removeStyles().then(() => { if ( typeof config.customTheme !== 'undefined' && config.customTheme && @@ -228,17 +228,17 @@ const buildReportTable = function ( .style('font-size', config.headerFontSize + 'px') .attr('draggable', true) .call(drag) - .on('mouseover', function(cell) { + .on('mouseover', function (cell) { d3.select('#tooltip') - .style('left', d3.event.x + 'px') - .style('top', d3.event.y + 'px') - .html(cell.label); + .style('left', d3.event.x + 'px') + .style('top', d3.event.y + 'px') + .html(cell.label); d3.select('#tooltip').classed('hidden', false); - return dropTarget = cell + return (dropTarget = cell); }) - .on('mouseout', function(cell) { + .on('mouseout', function (cell) { d3.select('#tooltip').classed('hidden', true); - return dropTarget = null + return (dropTarget = null); }); var table_rows = table @@ -527,7 +527,7 @@ const buildReportTable = function ( ); }; - renderTable().then(() => { + await renderTable().then(() => { document.getElementById('reportTable').classList.add('reveal'); if (config.customTheme === 'animate') { document.getElementById('visSvg').classList.remove('hidden'); @@ -639,12 +639,17 @@ looker.plugins.visualizations.add({ // console.log(config) var dataTable = new VisPluginTableModel(data, queryResponse, config); this.trigger('registerOptions', dataTable.getConfigOptions()); - buildReportTable(config, dataTable, updateColumnOrder, element); - - // DEBUG OUTPUT AND DONE - // console.log('dataTable', dataTable) - // console.log('container', document.getElementById('visContainer').parentNode) + buildReportTable(config, dataTable, updateColumnOrder, element) + .then(() => { + // DEBUG OUTPUT AND DONE + // console.log('dataTable', dataTable) + // console.log('container', document.getElementById('visContainer').parentNode) - done(); + done(); + }) + .catch(error => { + console.error(error); + done(); + }); }, }); From bf88535e1c8d240212aa2bb90c944f8f7294f0d3 Mon Sep 17 00:00:00 2001 From: Cinthia Elizabeth Villalejos Zamora Date: Mon, 7 Jul 2025 18:37:59 +0000 Subject: [PATCH 2/2] fix(bug): visualization not being rendered correctly in PDF delivery schedule fix --- src/report_table.js | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/report_table.js b/src/report_table.js index 656ebc3..723af89 100644 --- a/src/report_table.js +++ b/src/report_table.js @@ -42,20 +42,19 @@ const buildReportTable = async function ( const chartCentreX = bounds.x + bounds.width / 2; const chartCentreY = bounds.y + bounds.height / 2; - await removeStyles().then(() => { - if ( - typeof config.customTheme !== 'undefined' && - config.customTheme && - config.theme === 'custom' - ) { - loadStylesheet(config.customTheme); - } else if (typeof themes[config.theme] !== 'undefined') { - themes[config.theme].use(); - } - if (typeof themes[config.layout] !== 'undefined') { - themes[config.layout].use(); - } - }); + await removeStyles(); + if ( + typeof config.customTheme !== 'undefined' && + config.customTheme && + config.theme === 'custom' + ) { + loadStylesheet(config.customTheme); + } else if (typeof themes[config.theme] !== 'undefined') { + themes[config.theme].use(); + } + if (typeof themes[config.layout] !== 'undefined') { + themes[config.layout].use(); + } // Sort group based on sort order from looker const sortByColumnSeries = function (group) { @@ -644,11 +643,11 @@ looker.plugins.visualizations.add({ // DEBUG OUTPUT AND DONE // console.log('dataTable', dataTable) // console.log('container', document.getElementById('visContainer').parentNode) - - done(); }) .catch(error => { console.error(error); + }) + .finally(() => { done(); }); },