Skip to content

Commit e8596ed

Browse files
Merge branch 'development' of https://github.com/codeinwp/visualizer into issue-524
2 parents 6178e12 + b1c1447 commit e8596ed

File tree

5 files changed

+101
-94
lines changed

5 files changed

+101
-94
lines changed

classes/Visualizer/Gutenberg/build/block.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

classes/Visualizer/Gutenberg/src/Editor.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ class Editor extends Component {
102102
});
103103

104104
let result = await apiFetch({ path: `wp/v2/visualizer/${id}` });
105-
console.log( 'getChart', id, result );
106105

107106
this.setState({
108107
route: 'chartSelect',
@@ -308,7 +307,6 @@ class Editor extends Component {
308307
});
309308

310309
let result = await apiFetch({ path: `wp/v2/visualizer/${id}` });
311-
console.log( 'getChartData', id, result );
312310

313311
let chart = { ...this.state.chart };
314312

@@ -323,10 +321,11 @@ class Editor extends Component {
323321
});
324322
}
325323

326-
editChartData( chartData, type ) {
324+
editChartData( chartData, source ) {
327325
let chart = { ...this.state.chart };
328326
let series = [];
329327
let settings = { ...chart['visualizer-settings'] };
328+
let type = chart['visualizer-chart-type'];
330329
chartData[0].map( ( i, index ) => {
331330
series[index] = {
332331
label: i,
@@ -339,17 +338,17 @@ class Editor extends Component {
339338
let map = series;
340339
let fieldName = 'series';
341340

342-
if ( 'pie' === chart['visualizer-chart-type']) {
341+
if ( 'pie' === type ) {
343342
map = chartData;
344343
fieldName = 'slices';
345344
}
346345

347346
map.map( ( i, index ) => {
348-
if ( 'pie' !== chart['visualizer-chart-type'] && 0 === index ) {
347+
if ( 'pie' !== type && 0 === index ) {
349348
return;
350349
}
351350

352-
const seriesIndex = 'pie' !== chart['visualizer-chart-type'] ? index - 1 : index;
351+
const seriesIndex = 'pie' !== type ? index - 1 : index;
353352

354353
if ( settings[fieldName][seriesIndex] === undefined ) {
355354
settings[fieldName][seriesIndex] = {};
@@ -358,11 +357,11 @@ class Editor extends Component {
358357
});
359358

360359
settings[fieldName] = settings[fieldName].filter( ( i, index ) => {
361-
const length = 'pie' !== chart['visualizer-chart-type'] ? map.length - 1 : map.length;
360+
const length = -1 >= [ 'pie', 'tabular', 'dataTable' ].indexOf( type ) ? map.length - 1 : map.length;
362361
return index < length;
363362
});
364363

365-
chart['visualizer-source'] = type;
364+
chart['visualizer-source'] = source;
366365
chart['visualizer-default-data'] = 0;
367366
chart['visualizer-data'] = chartData;
368367
chart['visualizer-series'] = series;

classes/Visualizer/Module/Frontend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ public function renderChart( $atts ) {
375375
'map_api_key' => get_option( 'visualizer-map-api-key' ),
376376
'rest_url' => version_compare( $wp_version, '4.7.0', '>=' ) ? rest_url( 'visualizer/v' . VISUALIZER_REST_VERSION . '/action/#id#/#type#/' ) : '',
377377
'i10n' => array(
378-
'copied' => __( 'Copied!', 'visualizer' ),
378+
'copied' => __( 'The data has been copied to your clipboard. Hit Ctrl-V/Cmd-V in your spreadsheet editor to paste the data.', 'visualizer' ),
379379
),
380380
'page_type' => 'frontend',
381381
'is_front' => true,

js/render-facade.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
function initActionsButtons(v) {
88
if($('a.visualizer-action[data-visualizer-type=copy]').length > 0) {
9+
$('a.visualizer-action[data-visualizer-type=copy]').on('click', function(e) {
10+
e.preventDefault();
11+
});
912
var clipboard = new Clipboard('a.visualizer-action[data-visualizer-type=copy]'); // jshint ignore:line
1013
clipboard.on('success', function(e) {
1114
window.alert(v.i10n['copied']);
@@ -88,24 +91,23 @@
8891
document.body.dispatchEvent(event);
8992
};
9093

91-
// facade loads N times in the library (where N = the number of different chart libraries supported)
94+
// facade loads N times in the library and front end (where N = the number of different chart libraries supported)
9295
// so all charts are also loaded N times
9396
// this will ensure that no matter how many times facade is loaded, it initializes all charts only once.
9497
// fixed as part of the issue to add annotations.
95-
if(visualizer.page_type === 'library'){
96-
if(localStorage.getItem( 'viz-facade-loaded' ) === '1'){
97-
// prevent library from hanging.
98-
setTimeout( function(){
99-
localStorage.removeItem( 'viz-facade-loaded' );
100-
}, 2000);
101-
return;
102-
}
103-
localStorage.setItem( 'viz-facade-loaded', '1');
104-
// remove the flag so that repeated loading of the library does not cause problems.
98+
if(localStorage.getItem( 'viz-facade-loaded' ) === '1'){
99+
// prevent library from hanging.
105100
setTimeout( function(){
106101
localStorage.removeItem( 'viz-facade-loaded' );
107102
}, 2000);
103+
return;
108104
}
105+
localStorage.setItem( 'viz-facade-loaded', '1');
106+
// remove the flag so that repeated loading of the library does not cause problems.
107+
setTimeout( function(){
108+
localStorage.removeItem( 'viz-facade-loaded' );
109+
}, 2000);
110+
109111
$('body').trigger('visualizer:render:chart:start', visualizer);
110112
initActionsButtons(visualizer);
111113
registerDefaultActions();

0 commit comments

Comments
 (0)