diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bc171bde..ea7c9dbfd 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +#### [Version 3.8.0](https://github.com/Codeinwp/visualizer/compare/v3.7.12...v3.8.0) (2022-09-21) + +- Add data filter support for the charts + ##### [Version 3.7.12](https://github.com/Codeinwp/visualizer/compare/v3.7.11...v3.7.12) (2022-09-07) - Fixed compatibility issue with some themes and plugins [#933](https://github.com/Codeinwp/visualizer/issues/933) diff --git a/classes/Visualizer/Module/Chart.php b/classes/Visualizer/Module/Chart.php index 233ae6bc6..7dc438712 100644 --- a/classes/Visualizer/Module/Chart.php +++ b/classes/Visualizer/Module/Chart.php @@ -737,7 +737,7 @@ private function _handleDataAndSettingsPage() { $title = $this->_chart->ID; } $settings['internal_title'] = $title; - $settings_label = $settings['pieResidueSliceLabel']; + $settings_label = isset( $settings['pieResidueSliceLabel'] ) ? $settings['pieResidueSliceLabel'] : ''; if ( empty( $settings_label ) ) { $settings['pieResidueSliceLabel'] = esc_html__( 'Other', 'visualizer' ); } else { diff --git a/classes/Visualizer/Module/Frontend.php b/classes/Visualizer/Module/Frontend.php index a13c12421..27a21050c 100644 --- a/classes/Visualizer/Module/Frontend.php +++ b/classes/Visualizer/Module/Frontend.php @@ -395,6 +395,19 @@ public function renderChart( $atts ) { unset( $settings['chart-img'] ); } + $enable_controls = false; + if ( isset( $settings['controls'] ) && ! empty( $settings['controls']['controlType'] ) ) { + $column_index = $settings['controls']['filterColumnIndex']; + $column_label = $settings['controls']['filterColumnLabel']; + if ( 'false' !== $column_index || 'false' !== $column_label ) { + $enable_controls = true; + } + } + + if ( ! $enable_controls ) { + unset( $settings['controls'] ); + } + // add chart to the array $this->_charts[ $id ] = array( 'type' => $type, @@ -478,8 +491,11 @@ public function renderChart( $atts ) { if ( $type === 'tabular' ) { $prefix = 'T' . 'a' . 'bl' . 'e'; } + if ( Visualizer_Module::is_pro() && $enable_controls ) { + $actions_div .= '
'; + } // return placeholder div - return '
' . $actions_div . '
getHtmlAttributes( $attributes ) . '>
' . $this->addSchema( $chart->ID ) . ( ! Visualizer_Module::is_pro() ? ( '<' . 'di' . 'v st' . 'yl' . 'e="' . 'op' . 'a' . 'ci' . 't' . 'y:' . '0' . '.7' . ';t' . 'ex' . 't-a' . 'li' . 'gn:' . 'ri' . 'gh' . 't;b' . 'o' . 'tto' . 'm: 1' . '0px; z-i' . 'nd' . 'ex:1' . '00' . '0; ' . 'le' . 'ft' . ':2' . '0px' . '; fo' . 'nt-si' . 'ze: 1' . '4px">' . $prefix . ' b' . 'y' . ' V' . 'is' . 'u' . 'a' . 'l' . 'i' . 'z' . 'e' . 'r' . '' . '<' . '/' . 'd' . 'i' . 'v' . '>' ) : '' ) . '
'; + return '
' . $actions_div . '
getHtmlAttributes( $attributes ) . '>
' . $this->addSchema( $chart->ID ) . ( ! Visualizer_Module::is_pro() ? ( '<' . 'di' . 'v st' . 'yl' . 'e="' . 'op' . 'a' . 'ci' . 't' . 'y:' . '0' . '.7' . ';t' . 'ex' . 't-a' . 'li' . 'gn:' . 'ri' . 'gh' . 't;b' . 'o' . 'tto' . 'm: 1' . '0px; z-i' . 'nd' . 'ex:1' . '00' . '0; ' . 'le' . 'ft' . ':2' . '0px' . '; fo' . 'nt-si' . 'ze: 1' . '4px">' . $prefix . ' b' . 'y' . '
V' . 'is' . 'u' . 'a' . 'l' . 'i' . 'z' . 'e' . 'r' . '' . '<' . '/' . 'd' . 'i' . 'v' . '>' ) : '' ) . '
'; } /** diff --git a/classes/Visualizer/Plugin.php b/classes/Visualizer/Plugin.php index 7eee98915..dcee37129 100644 --- a/classes/Visualizer/Plugin.php +++ b/classes/Visualizer/Plugin.php @@ -28,7 +28,7 @@ class Visualizer_Plugin { const NAME = 'visualizer'; - const VERSION = '3.7.12'; + const VERSION = '3.8.0'; // custom post types const CPT_VISUALIZER = 'visualizer'; diff --git a/classes/Visualizer/Render/Library.php b/classes/Visualizer/Render/Library.php index 80416e499..1acfb257f 100644 --- a/classes/Visualizer/Render/Library.php +++ b/classes/Visualizer/Render/Library.php @@ -233,11 +233,20 @@ private function _renderLibrary() { foreach ( $this->charts as $placeholder_id => $chart ) { // show the sidebar after the first 3 charts. $count++; + $enable_controls = false; + $settings = isset( $chart['settings'] ) ? $chart['settings'] : array(); + if ( ! empty( $settings['controls']['controlType'] ) ) { + $column_index = $settings['controls']['filterColumnIndex']; + $column_label = $settings['controls']['filterColumnLabel']; + if ( 'false' !== $column_index || 'false' !== $column_label ) { + $enable_controls = true; + } + } if ( 3 === $count ) { $this->_renderSidebar(); - $this->_renderChartBox( $placeholder_id, $chart['id'] ); + $this->_renderChartBox( $placeholder_id, $chart['id'], $enable_controls ); } else { - $this->_renderChartBox( $placeholder_id, $chart['id'] ); + $this->_renderChartBox( $placeholder_id, $chart['id'], $enable_controls ); } } // show the sidebar if there are less than 3 charts. @@ -282,7 +291,7 @@ private function _renderLibrary() { * @param string $placeholder_id The placeholder's id for the chart. * @param int $chart_id The id of the chart. */ - private function _renderChartBox( $placeholder_id, $chart_id ) { + private function _renderChartBox( $placeholder_id, $chart_id, $with_filter = false ) { $settings = get_post_meta( $chart_id, Visualizer_Plugin::CF_SETTINGS ); $title = '#' . $chart_id; if ( ! empty( $settings[0]['title'] ) ) { @@ -336,9 +345,16 @@ private function _renderChartBox( $placeholder_id, $chart_id ) { } $shortcode = sprintf( '[visualizer id="%s" lazy="no" class=""]', $chart_id ); echo '
', esc_html( $title ), '
'; + if ( Visualizer_Module::is_pro() && $with_filter ) { + echo '
'; + echo '
'; + } echo '
'; echo ''; echo '
'; + if ( Visualizer_Module::is_pro() && $with_filter ) { + echo '
'; + } echo '