Skip to content

Commit acf5220

Browse files
Fix file conflict Codeinwp/visualizer-pro#315
2 parents d155ce4 + 5d1c9c8 commit acf5220

File tree

6 files changed

+97
-33
lines changed

6 files changed

+97
-33
lines changed

classes/Visualizer/Module.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -604,30 +604,29 @@ protected function load_chart_class_name( $chart_id ) {
604604
protected function get_inline_custom_css( $id, $settings ) {
605605
$css = '';
606606

607-
$arguments = array( '', $settings );
608-
if ( ! isset( $settings['customcss'] ) ) {
609-
return $arguments;
610-
}
611-
612607
$classes = array();
613608
$css = '<style type="text/css" name="visualizer-custom-css" id="customcss-' . $id . '">';
614-
foreach ( $settings['customcss'] as $name => $element ) {
615-
$attributes = array();
616-
foreach ( $element as $property => $value ) {
617-
$attributes[] = $this->handle_css_property( $property, $value );
618-
}
619-
$class_name = $id . $name;
620-
$properties = implode( ' !important; ', array_filter( $attributes ) );
621-
if ( ! empty( $properties ) ) {
622-
$css .= '.' . $class_name . ' {' . $properties . ' !important;}';
623-
$classes[ $name ] = $class_name;
609+
if ( ! empty( $settings['customcss'] ) ) {
610+
foreach ( $settings['customcss'] as $name => $element ) {
611+
$attributes = array();
612+
foreach ( $element as $property => $value ) {
613+
$attributes[] = $this->handle_css_property( $property, $value );
614+
}
615+
$class_name = $id . $name;
616+
$properties = implode( ' !important; ', array_filter( $attributes ) );
617+
if ( ! empty( $properties ) ) {
618+
$css .= '.' . $class_name . ' {' . $properties . ' !important;}';
619+
$classes[ $name ] = $class_name;
620+
}
624621
}
622+
$settings['cssClassNames'] = $classes;
625623
}
626-
$css .= '</style>';
627624

628-
$settings['cssClassNames'] = $classes;
625+
$img_path = VISUALIZER_ABSURL . 'images';
626+
$css .= ".locker,.locker-loader{position:absolute;top:0;left:0;width:100%;height:100%}.locker{z-index:1000;opacity:.8;background-color:#fff;-ms-filter:\"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)\";filter:alpha(opacity=80)}.locker-loader{z-index:1001;background:url($img_path/ajax-loader.gif) no-repeat center center}.dt-button{display:none!important}.visualizer-front-container.visualizer-lazy-render{content-visibility: auto;}";
627+
$css .= '</style>';
629628

630-
$arguments = array( $css, $settings );
629+
$arguments = array( $css, $settings );
631630
apply_filters_ref_array( 'visualizer_inline_css', array( &$arguments ) );
632631

633632
return $arguments;

classes/Visualizer/Module/Frontend.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ public function perform_action( WP_REST_Request $params ) {
271271
*/
272272
public function enqueueScripts() {
273273
wp_register_script( 'visualizer-customization', $this->get_user_customization_js(), array(), null, true );
274-
wp_register_style( 'visualizer-front', VISUALIZER_ABSURL . 'css/front.css', array(), Visualizer_Plugin::VERSION );
275274
do_action( 'visualizer_pro_frontend_load_resources' );
276275
}
277276

@@ -470,7 +469,6 @@ public function renderChart( $atts ) {
470469
)
471470
);
472471
}
473-
wp_enqueue_style( 'visualizer-front' );
474472

475473
// return placeholder div
476474
return '<div class="' . $container_class . '">' . $actions_div . '<div id="' . $id . '"' . $this->getHtmlAttributes( $attributes ) . '></div>' . $this->addSchema( $chart->ID ) . '</div>';

classes/Visualizer/Source/Query.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ public function fetch( $as_html = false, $results_as_numeric_array = false, $raw
115115
$wpdb->hide_errors();
116116
// @codingStandardsIgnoreStart
117117
$rows = $wpdb->get_results( $this->_query, $results_as_numeric_array ? ARRAY_N : ARRAY_A );
118-
do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Firing query %s to get results %s with error %s', $this->_query, print_r( $rows, true ), print_r( $wpdb->last_error, true ) ), 'debug', __FILE__, __LINE__ );
119118
// @codingStandardsIgnoreEnd
120119
$wpdb->show_errors();
121120

@@ -145,6 +144,9 @@ public function fetch( $as_html = false, $results_as_numeric_array = false, $raw
145144
$this->_error = $wpdb->last_error;
146145
}
147146
}
147+
// Query log.
148+
do_action( 'themeisle_log_event', Visualizer_Plugin::NAME, sprintf( 'Firing query %s to get results %s with error %s', $this->_query, print_r( $rows, true ), print_r( $wpdb->last_error, true ) ), 'debug', __FILE__, __LINE__ );
149+
148150
if ( $as_html ) {
149151
$results = $this->html( $headers, $results );
150152
} else {

js/render-chartjs.js

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
type = 'bar';
4848
break;
4949
case 'bar':
50-
type = 'horizontalBar';
50+
type = 'bar';
51+
settings.indexAxis = 'y';
5152
break;
5253
case 'pie':
5354
// donut is not a setting but a separate chart type.
@@ -200,10 +201,24 @@
200201
if(typeof settings['yAxes'] !== 'undefined' && typeof settings['xAxes'] !== 'undefined'){
201202
// stacking has to be defined on both axes.
202203
if(typeof settings['yAxes']['stacked_bool'] !== 'undefined'){
203-
settings['xAxes']['stacked_bool'] = 'true';
204+
settings['yAxes']['stacked_bool'] = 'true';
204205
}
205206
if(typeof settings['xAxes']['stacked_bool'] !== 'undefined'){
206-
settings['yAxes']['stacked_bool'] = 'true';
207+
settings['xAxes']['stacked_bool'] = 'true';
208+
}
209+
// Bar percentage.
210+
if (typeof settings['yAxes']['barPercentage_int'] !=='undefined' && ''!== settings['yAxes']['barPercentage_int']){
211+
settings['barPercentage'] = settings['yAxes']['barPercentage_int'];
212+
}
213+
if (typeof settings['xAxes']['barPercentage_int'] !=='undefined' && ''!== settings['xAxes']['barPercentage_int']){
214+
settings['barPercentage'] = settings['xAxes']['barPercentage_int'];
215+
}
216+
// Bar thickness.
217+
if (typeof settings['yAxes']['barThickness'] !=='undefined' && ''!== settings['yAxes']['barThickness']){
218+
settings['barThickness'] = settings['yAxes']['barThickness'];
219+
}
220+
if (typeof settings['xAxes']['barThickness'] !=='undefined' && ''!== settings['xAxes']['barThickness']){
221+
settings['barThickness'] = settings['xAxes']['barThickness'];
207222
}
208223
}
209224
configureAxes(settings, 'yAxes', chart);
@@ -275,6 +290,54 @@
275290
var $axis = $scales['scales'][axis];
276291

277292
$axis.push($features);
293+
// Migrate xAxes settings to v3.0+
294+
if ( $scales.scales && $scales.scales.xAxes ) {
295+
for (var x in $scales.scales.xAxes) {
296+
$scales.scales.x = {
297+
display: $scales.scales.xAxes[x].scaleLabel.display,
298+
title: {
299+
display:true,
300+
text: $scales.scales.xAxes[x].scaleLabel.labelString,
301+
color: $scales.scales.xAxes[x].scaleLabel.fontColor,
302+
font: {
303+
family: $scales.scales.xAxes[x].scaleLabel.fontFamily,
304+
size: $scales.scales.xAxes[x].scaleLabel.fontSize
305+
}
306+
},
307+
suggestedMax: $scales.scales.xAxes[x].ticks.suggestedMax || '',
308+
suggestedMin: $scales.scales.xAxes[x].ticks.suggestedMin || '',
309+
ticks: {
310+
maxTicksLimit: $scales.scales.xAxes[x].ticks.maxTicksLimit
311+
},
312+
stacked: $scales.scales.xAxes[x].stacked || false
313+
}
314+
}
315+
delete $scales.scales.xAxes;
316+
}
317+
// Migrate yAxes settings to v3.0+
318+
if ( $scales.scales && $scales.scales.yAxes ) {
319+
for (var y in $scales.scales.yAxes) {
320+
$scales.scales.y = {
321+
display: $scales.scales.yAxes[y].scaleLabel.display,
322+
title: {
323+
display:true,
324+
text: $scales.scales.yAxes[y].scaleLabel.labelString,
325+
color: $scales.scales.yAxes[y].scaleLabel.fontColor,
326+
font: {
327+
family: $scales.scales.yAxes[y].scaleLabel.fontFamily,
328+
size: $scales.scales.yAxes[y].scaleLabel.fontSize
329+
}
330+
},
331+
suggestedMax: $scales.scales.yAxes[y].ticks.suggestedMax || '',
332+
suggestedMin: $scales.scales.yAxes[y].ticks.suggestedMin || '',
333+
ticks: {
334+
maxTicksLimit: $scales.scales.yAxes[y].ticks.maxTicksLimit
335+
},
336+
stacked: $scales.scales.yAxes[y].stacked || false
337+
}
338+
}
339+
delete $scales.scales.yAxes;
340+
}
278341
$.extend(settings, $scales);
279342

280343
// to prevent duplication, indicates that the axis has been set.
@@ -288,12 +351,12 @@
288351
var format = settings[axis + '_format'];
289352
switch(axis){
290353
case 'xAxes':
291-
settings.scales.xAxes[0].ticks.callback = function(value, index, values){
354+
settings.scales.x.ticks.callback = function(value, index, values){
292355
return format_datum(value, format);
293356
};
294357
break;
295358
case 'yAxes':
296-
settings.scales.yAxes[0].ticks.callback = function(value, index, values){
359+
settings.scales.y.ticks.callback = function(value, index, values){
297360
return format_datum(value, format);
298361
};
299362
break;

js/render-facade.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
*/
120120
function showChart(id) {
121121
// clone the visualizer object so that the original object is not affected.
122-
var viz = Object.assign({}, visualizer);
122+
var viz = Object.assign(visualizer, window.visualizer || {});
123123
if(id){
124124
viz.id = id;
125125
}

js/render-google.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ var __visualizer_chart_images = [];
227227
delete axis.viewWindow[property];
228228
}
229229
}
230+
231+
if(settings.hAxis && settings.hAxis.format == ''){
232+
settings.hAxis.format = 'YYYY-MM-dd';
233+
}
230234
}
231235

232236
if(settings.hAxis){
@@ -235,9 +239,6 @@ var __visualizer_chart_images = [];
235239
settings.hAxis.textStyle = {color: settings.hAxis.textStyle};
236240
}
237241
}
238-
if(settings.hAxis.format == ''){
239-
settings.hAxis.format = 'YYYY-MM-dd';
240-
}
241242
}
242243

243244
if(settings.vAxis){
@@ -428,12 +429,13 @@ var __visualizer_chart_images = [];
428429
}, 500 );
429430
}
430431

431-
$( window ).on( 'orientationchange', function( event ) {
432-
$( '.visualizer-chart-loaded' ).removeClass( 'visualizer-chart-loaded' );
433-
} );
432+
window.addEventListener( 'orientationchange', function() {
433+
$( '.visualizer-chart-loaded' ).removeClass( 'visualizer-chart-loaded' ).resize();
434+
}, false);
434435
});
435436

436437
$(window).on('load', function(){
438+
$( '.visualizer-front:not(.visualizer-chart-loaded)' ).resize();
437439
resizeHiddenContainers(true);
438440
});
439441

0 commit comments

Comments
 (0)