PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.3
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.3
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 / SeriesSettings.js

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

270 lines 7.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 {
7 Component,
8 Fragment
9 } = wp.element;
10
11 const { ColorPalette } = wp.blockEditor || wp.editor;
12
13 const {
14 BaseControl,
15 ExternalLink,
16 PanelBody,
17 SelectControl,
18 TextControl
19 } = wp.components;
20
21 class SeriesSettings extends Component {
22 constructor() {
23 super( ...arguments );
24 }
25
26 componentDidMount() {
27
28 /**
29 * We use deep-clean to remove all empty properties which causes a major issue with Series Settings.
30 * So add a dummy property to make sure `series` object isn't empty.
31 * Should be removed before saving the data.
32 */
33 const settings = this.props.chart['visualizer-settings'];
34
35 Object.keys( settings.series )
36 .map( i => {
37 if ( settings.series[i] !== undefined ) {
38 settings.series[i].temp = 1;
39 }
40 }
41 );
42
43 this.props.edit( settings );
44 }
45
46 render() {
47
48 const type = this.props.chart['visualizer-chart-type'];
49
50 const settings = this.props.chart['visualizer-settings'];
51
52 const series = this.props.chart['visualizer-series'];
53
54 return (
55 <PanelBody
56 title={ __( 'Series Settings' ) }
57 initialOpen={ false }
58 className="visualizer-advanced-panel"
59 >
60
61 { Object.keys( settings.series )
62 .map( ( i, index ) => {
63 i = parseInt( i ) + 1;
64 let indexToFormat = parseInt( i );
65 let label = 'object' === typeof series[i] ? series[i].label : '';
66 let type = 'object' == typeof series[i] ? series[i].type : '';
67 let timer = 0;
68 if ( 'tabular' !== type ) {
69 indexToFormat = index;
70 }
71
72 i++;
73
74 return (
75 <PanelBody
76 title={ label }
77 className="visualizer-inner-sections"
78 initialOpen={ false }
79 >
80
81 { ( -1 >= [ 'tabular', 'pie' ].indexOf( type ) ) && (
82 <SelectControl
83 label={ __( 'Visible In Legend' ) }
84 help={ __( 'Determines whether the series has to be presented in the legend or not.' ) }
85 value={ settings.series[index].visibleInLegend ? settings.series[index].visibleInLegend : '1' }
86 options={ [
87 { label: __( 'Yes' ), value: '1' },
88 { label: __( 'No' ), value: '0' }
89 ] }
90 onChange={ e => {
91 settings.series[index].visibleInLegend = e;
92 this.props.edit( settings );
93 } }
94 />
95 ) }
96
97 { ( -1 >= [ 'tabular', 'candlestick', 'combo', 'column', 'bar' ].indexOf( type ) ) && (
98
99 <Fragment>
100
101 <TextControl
102 label={ __( 'Line Width' ) }
103 help={ __( 'Overrides the global line width value for this series.' ) }
104 value={ settings.series[index].lineWidth }
105 onChange={ e => {
106 settings.series[index].lineWidth = e;
107 this.props.edit( settings );
108 } }
109 onKeyUp={ e => {
110 clearTimeout( timer );
111 timer = setTimeout( () => {
112 if ( '' != settings.series[index].lineWidth && 0 >= settings.series[index].lineWidth ) {
113 settings.series[index].lineWidth = '0.1';
114 this.props.edit( settings );
115 }
116 }, 700 );
117 } }
118 />
119
120 <TextControl
121 label={ __( 'Point Size' ) }
122 help={ __( 'Overrides the global point size value for this series.' ) }
123 value={ settings.series[index].pointSize }
124 onChange={ e => {
125 settings.series[index].pointSize = e;
126 this.props.edit( settings );
127 } }
128 />
129
130 </Fragment>
131
132 ) }
133
134 { ( -1 >= [ 'candlestick' ].indexOf( type ) ) &&
135
136 ( type && 'number' === type ) ? (
137
138 <Fragment>
139
140 <TextControl
141 label={ __( 'Format' ) }
142 help={ __( 'Enter custom format pattern to apply to this series value.' ) }
143 value={ settings.series[indexToFormat].format }
144 onChange={ e => {
145 settings.series[indexToFormat].format = e;
146 this.props.edit( settings );
147 } }
148 />
149
150 <p>
151 { __( 'For number axis labels, this is a subset of the formatting ' ) }
152 <ExternalLink href="http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details">
153 { __( 'ICU pattern set.' ) }
154 </ExternalLink>
155 { __( ' For instance, $#,###.## will display values $1,234.56 for value 1234.56. Pay attention that if you use #%% percentage format then your values will be multiplied by 100.' ) }
156 </p>
157
158 </Fragment>
159
160 ) :
161
162 ( 0 <= [ 'date', 'datetime', 'timeofday' ].indexOf( type ) ) && (
163
164 <Fragment>
165
166 <TextControl
167 label={ __( 'Date Format' ) }
168 help={ __( 'Enter custom format pattern to apply to this series value.' ) }
169 placeholder="dd LLLL yyyy"
170 value={ settings.series[indexToFormat].format }
171 onChange={ e => {
172 settings.series[indexToFormat].format = e;
173 this.props.edit( settings );
174 } }
175 />
176
177 <p>
178 { __( 'This is a subset of the date formatting ' ) }
179 <ExternalLink href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax">
180 { __( 'ICU date and time format.' ) }
181 </ExternalLink>
182 </p>
183
184 </Fragment>
185
186 )
187
188 }
189
190 { ( 0 <= [ 'scatter', 'line' ].indexOf( type ) ) && (
191
192 <SelectControl
193 label={ __( 'Curve Type' ) }
194 help={ __( 'Determines whether the series has to be presented in the legend or not.' ) }
195 value={ settings.series[index].curveType ? settings.series[index].curveType : 'none' }
196 options={ [
197 { label: __( 'Straight line without curve' ), value: 'none' },
198 { label: __( 'The angles of the line will be smoothed' ), value: 'function' }
199 ] }
200 onChange={ e => {
201 settings.series[index].curveType = e;
202 this.props.edit( settings );
203 } }
204 />
205
206 ) }
207
208 { ( 0 <= [ 'area' ].indexOf( type ) ) && (
209
210 <TextControl
211 label={ __( 'Area Opacity' ) }
212 help={ __( 'The opacity of the colored area, where 0.0 is fully transparent and 1.0 is fully opaque.' ) }
213 value={ settings.series[index].areaOpacity }
214 onChange={ e => {
215 settings.series[index].areaOpacity = e;
216 this.props.edit( settings );
217 } }
218 />
219
220 ) }
221
222 { ( 0 <= [ 'combo' ].indexOf( type ) ) && (
223
224 <SelectControl
225 label={ __( 'Chart Type' ) }
226 help={ __( 'Select the type of chart to show for this series.' ) }
227 value={ settings.series[index].type ? settings.series[index].type : 'area' }
228 options={ [
229 { label: __( 'Area' ), value: 'area' },
230 { label: __( 'Bar' ), value: 'bars' },
231 { label: __( 'Candlesticks' ), value: 'candlesticks' },
232 { label: __( 'Line' ), value: 'line' },
233 { label: __( 'Stepped Area' ), value: 'steppedArea' }
234 ] }
235 onChange={ e => {
236 settings.series[index].type = e;
237 this.props.edit( settings );
238 } }
239 />
240
241 ) }
242
243 { ( -1 >= [ 'tabular' ].indexOf( type ) ) && (
244
245 <BaseControl
246 label={ __( 'Color' ) }
247 >
248 <ColorPalette
249 value={ settings.series[index].color }
250 onChange={ e => {
251 settings.series[index].color = e;
252 this.props.edit( settings );
253 } }
254 />
255 </BaseControl>
256
257 ) }
258
259 </PanelBody>
260 );
261 }
262 ) }
263
264 </PanelBody>
265 );
266 }
267 }
268
269 export default SeriesSettings;
270