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

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