Skip to content

Commit dbbbe30

Browse files
Add filter in preview and dashboard page Codeinwp/visualizer-pro#51
1 parent 4aa923d commit dbbbe30

File tree

7 files changed

+60
-7
lines changed

7 files changed

+60
-7
lines changed

classes/Visualizer/Render/Library.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,16 @@ private function _renderChartBox( $placeholder_id, $chart_id ) {
336336
}
337337
$shortcode = sprintf( '[visualizer id="%s" lazy="no" class=""]', $chart_id );
338338
echo '<div class="items"><div class="visualizer-chart"><div class="visualizer-chart-title">', esc_html( $title ), '</div>';
339+
if ( Visualizer_Module::is_pro() ) {
340+
echo '<div id="chart_wrapper_' . $placeholder_id . '">';
341+
echo '<div id="control_wrapper_' . $placeholder_id . '" class="vz-library-chart-filter"></div>';
342+
}
339343
echo '<div id="', $placeholder_id, '" class="visualizer-chart-canvas">';
340344
echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">';
341345
echo '</div>';
346+
if ( Visualizer_Module::is_pro() ) {
347+
echo '</div>';
348+
}
342349
echo '<div class="visualizer-chart-footer visualizer-clearfix">';
343350
echo '<a class="visualizer-chart-action visualizer-chart-delete" href="', $delete_url, '" title="', esc_attr__( 'Delete', 'visualizer' ), '" onclick="return showNotice.warn();"></a>';
344351
echo '<a class="visualizer-chart-action visualizer-chart-clone" href="', $clone_url, '" title="', esc_attr__( 'Clone', 'visualizer' ), '"></a>';

classes/Visualizer/Render/Page/Data.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,16 @@ protected function _renderContent() {
5757
$this->add_additional_content();
5858

5959
// Added by Ash/Upwork
60+
if ( Visualizer_Module::is_pro() ) {
61+
echo '<div id="chart_wrapper_canvas">';
62+
echo '<div id="control_wrapper_canvas"></div>';
63+
}
6064
echo '<div id="canvas">';
6165
echo '<img src="', VISUALIZER_ABSURL, 'images/ajax-loader.gif" class="loader">';
6266
echo '</div>';
67+
if ( Visualizer_Module::is_pro() ) {
68+
echo '</div>';
69+
}
6370
echo $this->custom_css;
6471
}
6572

classes/Visualizer/Render/Sidebar.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,8 @@ protected function _renderChartControlsSettings() {
621621
'DateRangeFilter' => esc_html__( 'Date Range Filter', 'visualizer' ),
622622
),
623623
'',
624-
false
624+
false,
625+
array( 'vz-controls-opt' )
625626
);
626627

627628
$column_index = [ 'false' => '' ];
@@ -638,10 +639,11 @@ protected function _renderChartControlsSettings() {
638639
self::_renderSelectItem(
639640
esc_html__( 'Filter By Column Index', 'visualizer' ),
640641
'controls[filterColumnIndex]',
641-
! empty( $this->controls['filterColumnIndex'] ) ? $this->controls['filterColumnIndex'] : '',
642+
isset( $this->controls['filterColumnIndex'] ) ? $this->controls['filterColumnIndex'] : '',
642643
$column_index,
643644
'',
644-
false
645+
false,
646+
array( 'vz-controls-opt' )
645647
);
646648

647649
self::_renderSelectItem(
@@ -650,7 +652,8 @@ protected function _renderChartControlsSettings() {
650652
! empty( $this->controls['filterColumnLabel'] ) ? $this->controls['filterColumnLabel'] : '',
651653
$column_label,
652654
'',
653-
false
655+
false,
656+
array( 'vz-controls-opt' )
654657
);
655658

656659
self::_renderSelectItem(

css/frame.css

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@
1717
bottom: 10px;
1818
left: 10px;
1919
}
20-
20+
#control_wrapper_canvas:not(:empty) {
21+
margin: 15px 0 0 5px;
22+
}
23+
#control_wrapper_canvas:not(:empty) + #canvas {
24+
top: 50px;
25+
}
26+
.goog-combobox input {
27+
min-height: auto;
28+
}
2129
.loader {
2230
position: absolute;
2331
top: 50%;
@@ -1528,6 +1536,6 @@ canvas.chartjs-render-monitor {
15281536
/******************************************************************************/
15291537
/******************************** Frontend Actions ***********************************/
15301538
/******************************************************************************/
1531-
#vz-frontend-actions .only-pro-inner {
1539+
#vz-frontend-actions .only-pro-inner, #vz-data-controls .only-pro-inner {
15321540
text-align: center;
15331541
}

css/library.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,17 @@ div#visualizer-types ul, div#visualizer-types form p {
424424
color: red;
425425
cursor: pointer;
426426
}
427+
.goog-combobox input {
428+
min-height: auto;
429+
}
430+
.vz-library-chart-filter:not(:empty) {
431+
background-color: #ffffff;
432+
padding: 5px 0 5px 5px;
433+
border: 1px solid #ddd;
434+
}
435+
.google-visualization-controls-rangefilter-thumblabel {
436+
padding: 0 !important;
437+
}
427438
@media (-webkit-min-device-pixel-ratio: 2) and (min-width: 1000px) and (max-width: 1600px) {
428439
#visualizer-sidebar.one-columns .visualizer-sidebar-box ul li:nth-child(+n+7) {
429440
display: none;

js/preview.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
v.charts.canvas.settings = settings;
5353
$('body').trigger('visualizer:render:currentchart:update', {visualizer: v});
5454
vizSettingsHaveChanged(true);
55-
}, 1000);
55+
}, 1500);
5656
}
5757

5858
function validateJSON() {
@@ -72,6 +72,19 @@
7272
});
7373
$('textarea[name="manual"]').change(validateJSON).keyup(validateJSON);
7474

75+
$( document ).on( 'change', '.vz-controls-opt', function() {
76+
$( '#control_wrapper_canvas' ).removeClass( 'no-filter' );
77+
var controlsOpt = $( '.vz-controls-opt' ).map(
78+
function() {
79+
var val = $(this).val();
80+
return '' !== val && 'false' !== val ? val : false ;
81+
}
82+
).get();
83+
controlsOpt = controlsOpt.filter( function(el) { return el; } );
84+
if ( controlsOpt.length === 0 ) {
85+
$( '#control_wrapper_canvas' ).addClass( 'no-filter' ).html('');
86+
}
87+
} );
7588
});
7689
})(jQuery, visualizer);
7790

js/render-google.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ var chartWrapperError = [];
7878
var controlWrapperElement = document.getElementById( "control_wrapper_" + id ) || null;
7979
var withControlMode = typeof settings.controls !== 'undefined' && controlWrapperElement ? true : false;
8080

81+
if ( $( controlWrapperElement ).hasClass( 'no-filter' ) ) {
82+
withControlMode = false;
83+
}
8184
if ( withControlMode ) {
8285
// Chart wrapper.
8386
render = new gv.ChartWrapper({
@@ -92,6 +95,7 @@ var chartWrapperError = [];
9295
gv.events.addListener(chartWrapper, 'error', function ( err ) {
9396
if ( chartWrapperError.length === 0 ) {
9497
chartWrapperError.push( err );
98+
gv.errors.removeError( err.id );
9599
var chartContainer = $( chartWrapperElement ).find( '.visualizer-front' );
96100
if ( chartContainer && chartContainer.is(':visible')) {
97101
if (chartContainer.parents('div').next( '#sidebar' ).length === 0) {

0 commit comments

Comments
 (0)