PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.9
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.9
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 3.10.4 All 148 releases
visualizer / classes / Visualizer / Gutenberg / src / Components / Sidebar / GeneralSettings.js

GeneralSettings.js in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.11.9, at classes/Visualizer/Gutenberg/src/Components/Sidebar/GeneralSettings.js

356 lines 11.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * WordPress dependencies
3 */
4 const { __ } = wp.i18n;
5
6 const { Component } = wp.element;
7
8 const { ColorPalette } = wp.blockEditor || wp.editor;
9
10 const {
11 BaseControl,
12 CheckboxControl,
13 PanelBody,
14 SelectControl,
15 TextControl
16 } = wp.components;
17
18 class GeneralSettings extends Component {
19 constructor() {
20 super( ...arguments );
21 }
22
23 render() {
24
25 const type = this.props.chart['visualizer-chart-type'];
26
27 const settings = this.props.chart['visualizer-settings'];
28
29 const tooltipTriggers = [ { label: __( 'The tooltip will be displayed when the user hovers over an element' ), value: 'focus' } ];
30
31 if ( -1 >= [ 'timeline' ].indexOf( type ) ) {
32 tooltipTriggers[1] = { label: __( 'The tooltip will be displayed when the user selects an element' ), value: 'selection' };
33 }
34
35 tooltipTriggers[2] = { label: __( 'The tooltip will not be displayed' ), value: 'none' };
36
37 let positions = [
38 { label: __( 'Left of the chart' ), value: 'left' },
39 { label: __( 'Right of the chart' ), value: 'right' },
40 { label: __( 'Above the chart' ), value: 'top' },
41 { label: __( 'Below the chart' ), value: 'bottom' },
42 { label: __( 'Omit the legend' ), value: 'none' }
43 ];
44
45 if ( 'pie' !== type ) {
46 positions.push({ label: __( 'Inside the chart' ), value: 'in' });
47 }
48
49 if ( 'bubble' === type ) {
50 positions = positions.filter( function( obj ) {
51 return 'left' !== obj.value;
52 });
53 }
54
55 let titleHelp = __( 'Text to display above the chart.' );
56 if ( 0 <= [ 'tabular', 'dataTable', 'gauge', 'geo', 'timeline' ].indexOf( type ) ) {
57 titleHelp = __( 'Text to display in the back-end admin area' );
58 }
59
60 return (
61 <PanelBody
62 title={ __( 'General Settings' ) }
63 initialOpen={ false }
64 className="visualizer-advanced-panel"
65 >
66
67 <PanelBody
68 title={ __( 'Title' ) }
69 className="visualizer-inner-sections"
70 initialOpen={ false }
71 >
72
73 <TextControl
74 label={ __( 'Chart Title' ) }
75 help={ titleHelp }
76 value={ settings.title }
77 onChange={ e => {
78 settings.title = e;
79 this.props.edit( settings );
80 } }
81 />
82
83 { ( -1 >= [ 'tabular', 'dataTable', 'gauge', 'geo', 'pie', 'timeline' ].indexOf( type ) ) && (
84 <SelectControl
85 label={ __( 'Chart Title Position' ) }
86 help={ __( 'Where to place the chart title, compared to the chart area.' ) }
87 value={ settings.titlePosition ? settings.titlePosition : 'out' }
88 options={ [
89 { label: __( 'Inside the chart' ), value: 'in' },
90 { label: __( 'Outside the chart' ), value: 'out' },
91 { label: __( 'None' ), value: 'none' }
92 ] }
93 onChange={ e => {
94 settings.titlePosition = e;
95 this.props.edit( settings );
96 } }
97 />
98 ) }
99
100 { ( -1 >= [ 'tabular', 'dataTable', 'gauge', 'geo', 'timeline' ].indexOf( type ) ) && (
101 <BaseControl
102 label={ __( 'Chart Title Color' ) }
103 >
104 <ColorPalette
105 value={ settings.titleTextStyle.color }
106 onChange={ e => {
107 settings.titleTextStyle.color = e;
108 this.props.edit( settings );
109 } }
110 />
111 </BaseControl>
112 ) }
113
114 { ( -1 >= [ 'tabular', 'dataTable', 'gauge', 'geo', 'pie', 'timeline' ].indexOf( type ) ) && (
115 <SelectControl
116 label={ __( 'Axes Titles Position' ) }
117 help={ __( 'Determines where to place the axis titles, compared to the chart area.' ) }
118 value={ settings.axisTitlesPosition ? settings.axisTitlesPosition : 'out' }
119 options={ [
120 { label: __( 'Inside the chart' ), value: 'in' },
121 { label: __( 'Outside the chart' ), value: 'out' },
122 { label: __( 'None' ), value: 'none' }
123 ] }
124 onChange={ e => {
125 settings.axisTitlesPosition = e;
126 this.props.edit( settings );
127 } }
128 />
129 ) }
130
131 </PanelBody>
132
133 { ( -1 >= [ 'tabular', 'dataTable', 'gauge', 'geo', 'pie', 'timeline' ].indexOf( type ) ) && (
134 <PanelBody
135 title={ __( 'Font Styles' ) }
136 className="visualizer-inner-sections"
137 initialOpen={ false }
138 >
139
140 <SelectControl
141 label={ __( 'Font Family' ) }
142 help={ __( 'The default font family for all text in the chart.' ) }
143 value={ settings.fontName ? settings.fontName : 'Arial' }
144 options={ [
145 { label: __( 'Arial' ), value: 'Arial' },
146 { label: __( 'Sans Serif' ), value: 'Sans Serif' },
147 { label: __( 'Serif' ), value: 'serif' },
148 { label: __( 'Arial' ), value: 'Arial' },
149 { label: __( 'Wide' ), value: 'Arial black' },
150 { label: __( 'Narrow' ), value: 'Arial Narrow' },
151 { label: __( 'Comic Sans MS' ), value: 'Comic Sans MS' },
152 { label: __( 'Courier New' ), value: 'Courier New' },
153 { label: __( 'Garamond' ), value: 'Garamond' },
154 { label: __( 'Georgia' ), value: 'Georgia' },
155 { label: __( 'Tahoma' ), value: 'Tahoma' },
156 { label: __( 'Verdana' ), value: 'Verdana' }
157 ] }
158 onChange={ e => {
159 settings.fontName = e;
160 this.props.edit( settings );
161 } }
162 />
163
164 <SelectControl
165 label={ __( 'Font Size' ) }
166 help={ __( 'The default font size for all text in the chart.' ) }
167 value={ settings.fontSize ? settings.fontSize : '15' }
168 options={ [
169 { label: '7', value: '7' },
170 { label: '8', value: '8' },
171 { label: '9', value: '9' },
172 { label: '10', value: '10' },
173 { label: '11', value: '11' },
174 { label: '12', value: '12' },
175 { label: '13', value: '13' },
176 { label: '14', value: '14' },
177 { label: '15', value: '15' },
178 { label: '16', value: '16' },
179 { label: '17', value: '17' },
180 { label: '18', value: '18' },
181 { label: '19', value: '19' },
182 { label: '20', value: '20' }
183 ] }
184 onChange={ e => {
185 settings.fontSize = e;
186 this.props.edit( settings );
187 } }
188 />
189
190 </PanelBody>
191 ) }
192
193 { ( -1 >= [ 'tabular', 'dataTable', 'gauge', 'geo', 'timeline' ].indexOf( type ) ) && (
194 <PanelBody
195 title={ __( 'Legend' ) }
196 className="visualizer-inner-sections"
197 initialOpen={ false }
198 >
199
200 <SelectControl
201 label={ __( 'Position' ) }
202 help={ __( 'Determines where to place the legend, compared to the chart area.' ) }
203 value={ settings.legend.position ? settings.legend.position : 'right' }
204 options={ positions }
205 onChange={ e => {
206 if ( 'pie' !== type ) {
207 let axis = 'left' === e ? 1 : 0;
208
209 if ( settings.series ) {
210 Object.keys( settings.series ).map( i => {
211 settings.series[i].targetAxisIndex = axis;
212 });
213 }
214 }
215
216 settings.legend.position = e;
217 this.props.edit( settings );
218 } }
219 />
220
221 <SelectControl
222 label={ __( 'Alignment' ) }
223 help={ __( 'Determines the alignment of the legend.' ) }
224 value={ settings.legend.alignment ? settings.legend.alignment : '15' }
225 options={ [
226 { label: __( 'Aligned to the start of the allocated area' ), value: 'start' },
227 { label: __( 'Centered in the allocated area' ), value: 'center' },
228 { label: __( 'Aligned to the end of the allocated area' ), value: 'end' }
229 ] }
230 onChange={ e => {
231 settings.legend.alignment = e;
232 this.props.edit( settings );
233 } }
234 />
235
236 <BaseControl
237 label={ __( 'Font Color' ) }
238 >
239 <ColorPalette
240 value={ settings.legend.textStyle.color }
241 onChange={ e => {
242 settings.legend.textStyle.color = e;
243 this.props.edit( settings );
244 } }
245 />
246 </BaseControl>
247
248 </PanelBody>
249 ) }
250
251 { ( -1 >= [ 'tabular', 'gauge', 'geo', 'dataTable', 'timeline' ].indexOf( type ) ) && (
252 <PanelBody
253 title={ __( 'Tooltip' ) }
254 className="visualizer-inner-sections"
255 initialOpen={ false }
256 >
257
258 <SelectControl
259 label={ __( 'Trigger' ) }
260 help={ __( 'Determines the user interaction that causes the tooltip to be displayed.' ) }
261 value={ settings.tooltip.trigger ? settings.tooltip.trigger : 'focus' }
262 options={ tooltipTriggers }
263 onChange={ e => {
264 settings.tooltip.trigger = e;
265 this.props.edit( settings );
266 } }
267 />
268
269 <SelectControl
270 label={ __( 'Show Color Code' ) }
271 help={ __( 'If set to yes, will show colored squares next to the slice information in the tooltip.' ) }
272 value={ settings.tooltip.showColorCode ? settings.tooltip.showColorCode : '0' }
273 options={ [
274 { label: __( 'Yes' ), value: '1' },
275 { label: __( 'No' ), value: '0' }
276 ] }
277 onChange={ e => {
278 settings.tooltip.showColorCode = e;
279 this.props.edit( settings );
280 } }
281 />
282
283 { ( 0 <= [ 'pie' ].indexOf( type ) ) && (
284 <SelectControl
285 label={ __( 'Text' ) }
286 help={ __( 'Determines what information to display when the user hovers over a pie slice.' ) }
287 value={ settings.tooltip.text ? settings.tooltip.text : 'both' }
288 options={ [
289 { label: __( 'Display both the absolute value of the slice and the percentage of the whole' ), value: 'both' },
290 { label: __( 'Display only the absolute value of the slice' ), value: 'value' },
291 { label: __( 'Display only the percentage of the whole represented by the slice' ), value: 'percentage' }
292 ] }
293 onChange={ e => {
294 settings.tooltip.text = e;
295 this.props.edit( settings );
296 } }
297 />
298 ) }
299
300 </PanelBody>
301 ) }
302
303 { ( -1 >= [ 'tabular', 'dataTable', 'gauge', 'geo', 'pie', 'timeline' ].indexOf( type ) ) && (
304 <PanelBody
305 title={ __( 'Animation' ) }
306 className="visualizer-inner-sections"
307 initialOpen={ false }
308 >
309
310 <CheckboxControl
311 label={ __( 'Animate on startup?' ) }
312 help={ __( 'Determines if the chart will animate on the initial draw.' ) }
313 checked={ Number( settings.animation.startup ) }
314 onChange={ e => {
315 settings.animation.startup = e ? '1' : '0';
316 this.props.edit( settings );
317 } }
318 />
319
320 <TextControl
321 label={ __( 'Duration' ) }
322 help={ __( 'The duration of the animation, in milliseconds.' ) }
323 type="number"
324 value={ settings.animation.duration }
325 onChange={ e => {
326 settings.animation.duration = e;
327 this.props.edit( settings );
328 } }
329 />
330
331 <SelectControl
332 label={ __( 'Easing' ) }
333 help={ __( 'The easing function applied to the animation.' ) }
334 value={ settings.animation.easing ? settings.animation.easing : 'linear' }
335 options={ [
336 { label: __( 'Constant speed' ), value: 'linear' },
337 { label: __( 'Start slow and speed up' ), value: 'in' },
338 { label: __( 'Start fast and slow down' ), value: 'out' },
339 { label: __( 'Start slow, speed up, then slow down' ), value: 'inAndOut' }
340 ] }
341 onChange={ e => {
342 settings.animation.easing = e;
343 this.props.edit( settings );
344 } }
345 />
346
347 </PanelBody>
348 ) }
349
350 </PanelBody>
351 );
352 }
353 }
354
355 export default GeneralSettings;
356