Skip to content

Commit 0fe18ef

Browse files
Merge pull request #605 from contactashish13/issue-602-1
Having SCRIPT_DEBUG on causes issues in real time update of charts
2 parents 89a30cb + 1d37b21 commit 0fe18ef

File tree

7 files changed

+1769
-725
lines changed

7 files changed

+1769
-725
lines changed

classes/Visualizer/Render/Page/Update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function _toHTML() {
5151
if ( $this->settings ) {
5252
echo 'win.visualizer.charts.canvas.settings = ', $this->settings, ';';
5353
}
54-
echo 'win.visualizer.update();';
54+
echo 'win.updateChartPreview();';
5555

5656
echo $this->updateEditorAndSettings();
5757

js/preview.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
delete settings['height'];
3434

3535
v.charts.canvas.settings = settings;
36-
v.update();
36+
$('body').trigger('visualizer:render:currentchart:update', {visualizer: v});
3737
}, 1000);
3838
}
3939

js/render-chartjs.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,6 @@
385385
}
386386
}
387387

388-
if(typeof visualizer !== 'undefined'){
389-
// called while updating the chart.
390-
visualizer.update = function(){
391-
renderChart('canvas', visualizer);
392-
};
393-
}
394-
395388
$('body').on('visualizer:render:chart:start', function(event, v){
396389
all_charts = v.charts;
397390
render(v);
@@ -407,6 +400,11 @@
407400
renderSpecificChart(v.id, v.chart, v.v);
408401
});
409402

403+
$('body').on('visualizer:render:currentchart:update', function(event, v){
404+
var data = v || event.detail;
405+
renderChart('canvas', data.visualizer);
406+
});
407+
410408
// front end actions
411409
$('body').on('visualizer:action:specificchart', function(event, v){
412410
switch(v.action){

js/render-datatables.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,6 @@
278278
}
279279
}
280280

281-
if(typeof visualizer !== 'undefined'){
282-
// called while updating the chart.
283-
visualizer.update = function(){
284-
renderSpecificChart('canvas', all_charts['canvas'], visualizer);
285-
};
286-
}
287-
288281
$('body').on('visualizer:render:chart:start', function(event, v){
289282
all_charts = v.charts;
290283
render(v);
@@ -294,6 +287,11 @@
294287
renderSpecificChart(v.id, v.chart, v.v);
295288
});
296289

290+
$('body').on('visualizer:render:currentchart:update', function(event, v){
291+
var data = v || event.detail;
292+
renderSpecificChart('canvas', all_charts['canvas'], data.visualizer);
293+
});
294+
297295
// front end actions
298296
$('body').on('visualizer:action:specificchart', function(event, v){
299297
switch(v.action){

js/render-facade.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@
8181
}
8282

8383
$(document).ready(function(){
84+
85+
// for updating the currently displayed chart (preview mode)
86+
window.updateChartPreview = function(){
87+
var event = new CustomEvent('visualizer:render:currentchart:update', {detail: {visualizer: visualizer}});
88+
document.body.dispatchEvent(event);
89+
};
90+
8491
// facade loads N times in the library (where N = the number of different chart libraries supported)
8592
// so all charts are also loaded N times
8693
// this will ensure that no matter how many times facade is loaded, it initializes all charts only once.
@@ -168,4 +175,4 @@
168175

169176
return $(this);
170177
};
171-
})(jQuery);
178+
})(jQuery);

js/render-google.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -319,14 +319,6 @@ var __visualizer_chart_images = [];
319319
}
320320
}
321321

322-
if(typeof visualizer !== 'undefined'){
323-
// called while updating the chart.
324-
visualizer.update = function(){
325-
renderChart('canvas');
326-
};
327-
}
328-
329-
330322
var resizeTimeout;
331323

332324
$(document).ready(function() {
@@ -421,6 +413,10 @@ var __visualizer_chart_images = [];
421413
renderSpecificChart(v.id, v.chart);
422414
});
423415

416+
$('body').on('visualizer:render:currentchart:update', function(event, v){
417+
renderChart('canvas');
418+
});
419+
424420
// front end actions
425421
$('body').on('visualizer:action:specificchart', function(event, v){
426422
switch(v.action){

0 commit comments

Comments
 (0)