PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.4.5
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.4.5
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.4.5, at classes/Visualizer/Gutenberg/src/Components/Sidebar/GeneralSettings.js

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