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

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

260 lines 7.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 {
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 let indexToFormat = parseInt( i );
64 let label = series[i].label || '';
65 let type = series[i].type || '';
66
67 if ( 'tabular' !== type ) {
68 indexToFormat = index;
69 }
70
71 i++;
72
73 return (
74 <PanelBody
75 title={ label }
76 className="visualizer-inner-sections"
77 initialOpen={ false }
78 >
79
80 { ( -1 >= [ 'tabular', 'pie' ].indexOf( type ) ) && (
81 <SelectControl
82 label={ __( 'Visible In Legend' ) }
83 help={ __( 'Determines whether the series has to be presented in the legend or not.' ) }
84 value={ settings.series[index].visibleInLegend ? settings.series[index].visibleInLegend : '1' }
85 options={ [
86 { label: __( 'Yes' ), value: '1' },
87 { label: __( 'No' ), value: '0' }
88 ] }
89 onChange={ e => {
90 settings.series[index].visibleInLegend = e;
91 this.props.edit( settings );
92 } }
93 />
94 ) }
95
96 { ( -1 >= [ 'tabular', 'candlestick', 'combo', 'column', 'bar' ].indexOf( type ) ) && (
97
98 <Fragment>
99
100 <TextControl
101 label={ __( 'Line Width' ) }
102 help={ __( 'Overrides the global line width value for this series.' ) }
103 value={ settings.series[index].lineWidth }
104 onChange={ e => {
105 settings.series[index].lineWidth = e;
106 this.props.edit( settings );
107 } }
108 />
109
110 <TextControl
111 label={ __( 'Point Size' ) }
112 help={ __( 'Overrides the global point size value for this series.' ) }
113 value={ settings.series[index].pointSize }
114 onChange={ e => {
115 settings.series[index].pointSize = e;
116 this.props.edit( settings );
117 } }
118 />
119
120 </Fragment>
121
122 ) }
123
124 { ( -1 >= [ 'candlestick' ].indexOf( type ) ) &&
125
126 ( type && 'number' === type ) ? (
127
128 <Fragment>
129
130 <TextControl
131 label={ __( 'Format' ) }
132 help={ __( 'Enter custom format pattern to apply to this series value.' ) }
133 value={ settings.series[indexToFormat].format }
134 onChange={ e => {
135 settings.series[indexToFormat].format = e;
136 this.props.edit( settings );
137 } }
138 />
139
140 <p>
141 { __( 'For number axis labels, this is a subset of the formatting ' ) }
142 <ExternalLink href="http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details">
143 { __( 'ICU pattern set.' ) }
144 </ExternalLink>
145 { __( ' 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.' ) }
146 </p>
147
148 </Fragment>
149
150 ) :
151
152 ( 0 <= [ 'date', 'datetime', 'timeofday' ].indexOf( type ) ) && (
153
154 <Fragment>
155
156 <TextControl
157 label={ __( 'Date Format' ) }
158 help={ __( 'Enter custom format pattern to apply to this series value.' ) }
159 placeholder="dd LLLL yyyy"
160 value={ settings.series[indexToFormat].format }
161 onChange={ e => {
162 settings.series[indexToFormat].format = e;
163 this.props.edit( settings );
164 } }
165 />
166
167 <p>
168 { __( 'This is a subset of the date formatting ' ) }
169 <ExternalLink href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax">
170 { __( 'ICU date and time format.' ) }
171 </ExternalLink>
172 </p>
173
174 </Fragment>
175
176 )
177
178 }
179
180 { ( 0 <= [ 'scatter', 'line' ].indexOf( type ) ) && (
181
182 <SelectControl
183 label={ __( 'Curve Type' ) }
184 help={ __( 'Determines whether the series has to be presented in the legend or not.' ) }
185 value={ settings.series[index].curveType ? settings.series[index].curveType : 'none' }
186 options={ [
187 { label: __( 'Straight line without curve' ), value: 'none' },
188 { label: __( 'The angles of the line will be smoothed' ), value: 'function' }
189 ] }
190 onChange={ e => {
191 settings.series[index].curveType = e;
192 this.props.edit( settings );
193 } }
194 />
195
196 ) }
197
198 { ( 0 <= [ 'area' ].indexOf( type ) ) && (
199
200 <TextControl
201 label={ __( 'Area Opacity' ) }
202 help={ __( 'The opacity of the colored area, where 0.0 is fully transparent and 1.0 is fully opaque.' ) }
203 value={ settings.series[index].areaOpacity }
204 onChange={ e => {
205 settings.series[index].areaOpacity = e;
206 this.props.edit( settings );
207 } }
208 />
209
210 ) }
211
212 { ( 0 <= [ 'combo' ].indexOf( type ) ) && (
213
214 <SelectControl
215 label={ __( 'Chart Type' ) }
216 help={ __( 'Select the type of chart to show for this series.' ) }
217 value={ settings.series[index].type ? settings.series[index].type : 'area' }
218 options={ [
219 { label: __( 'Area' ), value: 'area' },
220 { label: __( 'Bar' ), value: 'bars' },
221 { label: __( 'Candlesticks' ), value: 'candlesticks' },
222 { label: __( 'Line' ), value: 'line' },
223 { label: __( 'Stepped Area' ), value: 'steppedArea' }
224 ] }
225 onChange={ e => {
226 settings.series[index].type = e;
227 this.props.edit( settings );
228 } }
229 />
230
231 ) }
232
233 { ( -1 >= [ 'tabular' ].indexOf( type ) ) && (
234
235 <BaseControl
236 label={ __( 'Color' ) }
237 >
238 <ColorPalette
239 value={ settings.series[index].color }
240 onChange={ e => {
241 settings.series[index].color = e;
242 this.props.edit( settings );
243 } }
244 />
245 </BaseControl>
246
247 ) }
248
249 </PanelBody>
250 );
251 }
252 ) }
253
254 </PanelBody>
255 );
256 }
257 }
258
259 export default SeriesSettings;
260