Skip to content

Commit 37e707d

Browse files
author
Eugene Manuilov
committed
Implemented ability to edit tooltip settings
1 parent 3c0888d commit 37e707d

File tree

6 files changed

+83
-8
lines changed

6 files changed

+83
-8
lines changed

classes/Visualizer/Render/Sidebar.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,43 @@ protected function _renderGeneralSettings() {
213213
'#000'
214214
);
215215
self::_renderSectionEnd();
216+
217+
self::_renderSectionStart( esc_html__( 'Tooltip', Visualizer_Plugin::NAME ), false );
218+
$this->_renderTooltipSettigns();
219+
self::_renderSectionEnd();
216220
self::_renderGroupEnd();
217221
}
218222

223+
/**
224+
* Renders tooltip settings section.
225+
*
226+
* @since 1.4.0
227+
*
228+
* @access protected
229+
*/
230+
protected function _renderTooltipSettigns() {
231+
self::_renderSelectItem(
232+
esc_html__( 'Trigger', Visualizer_Plugin::NAME ),
233+
'tooltip[trigger]',
234+
isset( $this->tooltip['trigger'] ) ? $this->tooltip['trigger'] : null,
235+
array(
236+
'' => '',
237+
'focus' => esc_html__( 'The tooltip will be displayed when the user hovers over an element', Visualizer_Plugin::NAME ),
238+
'selection' => esc_html__( 'The tooltip will be displayed when the user selects an element', Visualizer_Plugin::NAME ),
239+
'none' => esc_html__( 'The tooltip will not be displayed', Visualizer_Plugin::NAME ),
240+
),
241+
esc_html__( 'Determines the user interaction that causes the tooltip to be displayed.', Visualizer_Plugin::NAME )
242+
);
243+
244+
self::_renderSelectItem(
245+
esc_html__( 'Show Color Code', Visualizer_Plugin::NAME ),
246+
'tooltip[showColorCode]',
247+
isset( $this->tooltip['showColorCode'] ) ? $this->tooltip['showColorCode'] : null,
248+
$this->_yesno,
249+
esc_html__( 'If set to yes, will show colored squares next to the slice information in the tooltip.', Visualizer_Plugin::NAME )
250+
);
251+
}
252+
219253
/**
220254
* Renders chart view settings group.
221255
*

classes/Visualizer/Render/Sidebar/Type/Geo.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,33 @@ protected function _renderMapSettings() {
125125
''
126126
);
127127
self::_renderSectionEnd();
128+
self::_renderSectionStart( esc_html__( 'Tooltip', Visualizer_Plugin::NAME ), false );
129+
$this->_renderTooltipSettigns();
130+
self::_renderSectionEnd();
128131
self::_renderGroupEnd();
129132
}
130133

134+
/**
135+
* Renders tooltip settings section.
136+
*
137+
* @since 1.4.0
138+
*
139+
* @access protected
140+
*/
141+
protected function _renderTooltipSettigns() {
142+
self::_renderSelectItem(
143+
esc_html__( 'Trigger', Visualizer_Plugin::NAME ),
144+
'tooltip[trigger]',
145+
isset( $this->tooltip['trigger'] ) ? $this->tooltip['trigger'] : null,
146+
array(
147+
'' => '',
148+
'focus' => esc_html__( 'The tooltip will be displayed when the user hovers over an element', Visualizer_Plugin::NAME ),
149+
'none' => esc_html__( 'The tooltip will not be displayed', Visualizer_Plugin::NAME ),
150+
),
151+
esc_html__( 'Determines the user interaction that causes the tooltip to be displayed.', Visualizer_Plugin::NAME )
152+
);
153+
}
154+
131155
/**
132156
* Renders color axis settings group.
133157
*

classes/Visualizer/Render/Sidebar/Type/Pie.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,28 @@ protected function _renderSlicesSettings() {
179179
self::_renderGroupEnd();
180180
}
181181

182+
/**
183+
* Renders tooltip settings section.
184+
*
185+
* @since 1.4.0
186+
*
187+
* @access protected
188+
*/
189+
protected function _renderTooltipSettigns() {
190+
parent::_renderTooltipSettigns();
191+
192+
self::_renderSelectItem(
193+
esc_html__( 'Text', Visualizer_Plugin::NAME ),
194+
'tooltip[text]',
195+
isset( $this->tooltip['text'] ) ? $this->tooltip['text'] : null,
196+
array(
197+
'' => '',
198+
'both' => esc_html__( 'Display both the absolute value of the slice and the percentage of the whole', Visualizer_Plugin::NAME ),
199+
'value' => esc_html__( 'Display only the absolute value of the slice', Visualizer_Plugin::NAME ),
200+
'percentage' => esc_html__( 'Display only the percentage of the whole represented by the slice', Visualizer_Plugin::NAME ),
201+
),
202+
esc_html__( 'Determines what information to display when the user hovers over a pie slice.', Visualizer_Plugin::NAME )
203+
);
204+
}
205+
182206
}

js/media/view.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@
5454
settings.width = self.options.width;
5555
settings.height = self.options.height;
5656

57-
if (settings.tooltip == undefined) {
58-
settings.tooltip = {trigger: 'selection'};
59-
}
60-
6157
table = new gv.DataTable({cols: series});
6258
chart = type == 'gauge' ? 'Gauge' : type.charAt(0).toUpperCase() + type.slice(1) + 'Chart';
6359
chart = new gv[chart](self.el);

js/render.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
data = chart.data;
1212
settings = chart.settings;
1313

14-
if (settings.tooltip == undefined) {
15-
settings.tooltip = {trigger: 'selection'};
16-
}
17-
1814
container = document.getElementById(id);
1915
table = new gv.DataTable({cols: series});
2016

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Pay attention that to turn your shortcodes into graphs, your theme has to have `
5959
== Changelog ==
6060

6161
= 1.4 =
62+
* Implemented ability to edit tooltip settings
6263
* Implemented new settings for linear charts like selection mode and aggregation target
6364
* Implemented area opacity setting for area chart
6465
* Implemented new settings for pie chart like pie hole, start angle and slice offset

0 commit comments

Comments
 (0)