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

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