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

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