visualizer
/
classes
/
Visualizer
/
Gutenberg
/
src
/
Components
/
Sidebar
/
VerticalAxisSettings.js
VerticalAxisSettings.js in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.5.1, at classes/Visualizer/Gutenberg/src/Components/Sidebar/VerticalAxisSettings.js
| 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 VerticalAxisSettings extends Component { |
| 22 | constructor() { |
| 23 | super( ...arguments ); |
| 24 | } |
| 25 | |
| 26 | render() { |
| 27 | |
| 28 | const type = this.props.chart['visualizer-chart-type']; |
| 29 | |
| 30 | const settings = this.props.chart['visualizer-settings']; |
| 31 | |
| 32 | return ( |
| 33 | <PanelBody |
| 34 | title={ __( 'Vertical Axis Settings' ) } |
| 35 | initialOpen={ false } |
| 36 | className="visualizer-advanced-panel" |
| 37 | > |
| 38 | |
| 39 | <PanelBody |
| 40 | title={ __( 'General Settings' ) } |
| 41 | className="visualizer-inner-sections" |
| 42 | initialOpen={ false } |
| 43 | > |
| 44 | |
| 45 | <TextControl |
| 46 | label={ __( 'Axis Title' ) } |
| 47 | help={ __( 'The title of the Vertical axis.' ) } |
| 48 | value={ settings.vAxis.title } |
| 49 | onChange={ e => { |
| 50 | settings.vAxis.title = e; |
| 51 | this.props.edit( settings ); |
| 52 | } } |
| 53 | /> |
| 54 | |
| 55 | <SelectControl |
| 56 | label={ __( 'Text Position' ) } |
| 57 | help={ __( 'Position of the Vertical axis text, relative to the chart area.' ) } |
| 58 | value={ settings.vAxis.textPosition ? settings.vAxis.textPosition : 'out' } |
| 59 | options={ [ |
| 60 | { label: __( 'Inside the chart' ), value: 'in' }, |
| 61 | { label: __( 'Outside the chart' ), value: 'out' }, |
| 62 | { label: __( 'None' ), value: 'none' } |
| 63 | ] } |
| 64 | onChange={ e => { |
| 65 | settings.vAxis.textPosition = e; |
| 66 | this.props.edit( settings ); |
| 67 | } } |
| 68 | /> |
| 69 | |
| 70 | <SelectControl |
| 71 | label={ __( 'Direction' ) } |
| 72 | help={ __( 'The direction in which the values along the Vertical axis grow.' ) } |
| 73 | value={ settings.vAxis.direction ? settings.vAxis.direction : '1' } |
| 74 | options={ [ |
| 75 | { label: __( 'Identical Direction' ), value: '1' }, |
| 76 | { label: __( 'Reverse Direction' ), value: '-1' } |
| 77 | ] } |
| 78 | onChange={ e => { |
| 79 | settings.vAxis.direction = e; |
| 80 | this.props.edit( settings ); |
| 81 | } } |
| 82 | /> |
| 83 | |
| 84 | <BaseControl |
| 85 | label={ __( 'Base Line Color' ) } |
| 86 | > |
| 87 | <ColorPalette |
| 88 | value={ settings.vAxis.baselineColor } |
| 89 | onChange={ e => { |
| 90 | settings.vAxis.baselineColor = e; |
| 91 | this.props.edit( settings ); |
| 92 | } } |
| 93 | /> |
| 94 | </BaseControl> |
| 95 | |
| 96 | <BaseControl |
| 97 | label={ __( 'Axis Text Color' ) } |
| 98 | > |
| 99 | <ColorPalette |
| 100 | value={ settings.vAxis.textStyle.color || settings.vAxis.textStyle } |
| 101 | onChange={ e => { |
| 102 | settings.vAxis.textStyle = {}; |
| 103 | settings.vAxis.textStyle.color = e; |
| 104 | this.props.edit( settings ); |
| 105 | } } |
| 106 | /> |
| 107 | </BaseControl> |
| 108 | |
| 109 | { ( -1 >= [ 'bar' ].indexOf( type ) ) && ( |
| 110 | <Fragment> |
| 111 | |
| 112 | <TextControl |
| 113 | label={ __( 'Number Format' ) } |
| 114 | help={ __( 'Enter custom format pattern to apply to Vertical axis labels.' ) } |
| 115 | value={ settings.vAxis.format } |
| 116 | onChange={ e => { |
| 117 | settings.vAxis.format = e; |
| 118 | this.props.edit( settings ); |
| 119 | } } |
| 120 | /> |
| 121 | |
| 122 | <p> |
| 123 | { __( 'For number axis labels, this is a subset of the formatting ' ) } |
| 124 | <ExternalLink href="http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details"> |
| 125 | { __( 'ICU pattern set.' ) } |
| 126 | </ExternalLink> |
| 127 | { __( ' 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.' ) } |
| 128 | </p> |
| 129 | |
| 130 | <p> |
| 131 | { __( 'For date axis labels, this is a subset of the date formatting ' ) } |
| 132 | <ExternalLink href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax"> |
| 133 | { __( 'ICU date and time format.' ) } |
| 134 | </ExternalLink> |
| 135 | </p> |
| 136 | |
| 137 | </Fragment> |
| 138 | ) } |
| 139 | |
| 140 | </PanelBody> |
| 141 | |
| 142 | { ( -1 >= [ 'bar' ].indexOf( type ) ) && ( |
| 143 | |
| 144 | <Fragment> |
| 145 | |
| 146 | <PanelBody |
| 147 | title={ __( 'Grid Lines' ) } |
| 148 | className="visualizer-inner-sections" |
| 149 | initialOpen={ false } |
| 150 | > |
| 151 | |
| 152 | <TextControl |
| 153 | label={ __( 'Count' ) } |
| 154 | help={ __( 'The approximate number of vertical gridlines inside the chart area. You can specify a value of -1 to automatically compute the number of gridlines, 0 or 1 to draw no gridlines, or 2 or more to only draw gridline. Any number greater than 2 will be used to compute the minSpacing between gridlines.' ) } |
| 155 | value={ settings.vAxis.gridlines ? settings.vAxis.gridlines.count : '' } |
| 156 | onChange={ e => { |
| 157 | if ( ! settings.vAxis.gridlines ) { |
| 158 | settings.vAxis.gridlines = {}; |
| 159 | } |
| 160 | |
| 161 | settings.vAxis.gridlines.count = e; |
| 162 | this.props.edit( settings ); |
| 163 | } } |
| 164 | /> |
| 165 | |
| 166 | <BaseControl |
| 167 | label={ __( 'Color' ) } |
| 168 | > |
| 169 | <ColorPalette |
| 170 | value={ settings.vAxis.gridlines ? settings.vAxis.gridlines.color : '' } |
| 171 | onChange={ e => { |
| 172 | if ( ! settings.vAxis.gridlines ) { |
| 173 | settings.vAxis.gridlines = {}; |
| 174 | } |
| 175 | |
| 176 | settings.vAxis.gridlines.color = e; |
| 177 | this.props.edit( settings ); |
| 178 | } } |
| 179 | /> |
| 180 | </BaseControl> |
| 181 | |
| 182 | </PanelBody> |
| 183 | |
| 184 | <PanelBody |
| 185 | title={ __( 'Minor Grid Lines' ) } |
| 186 | className="visualizer-inner-sections" |
| 187 | initialOpen={ false } |
| 188 | > |
| 189 | |
| 190 | <TextControl |
| 191 | label={ __( 'Count' ) } |
| 192 | help={ __( 'Specify 0 to disable the minor gridlines.' ) } |
| 193 | value={ settings.vAxis.minorGridlines ? settings.vAxis.minorGridlines.count : '' } |
| 194 | onChange={ e => { |
| 195 | if ( ! settings.vAxis.minorGridlines ) { |
| 196 | settings.vAxis.minorGridlines = {}; |
| 197 | } |
| 198 | settings.vAxis.minorGridlines.count = e; |
| 199 | this.props.edit( settings ); |
| 200 | } } |
| 201 | /> |
| 202 | |
| 203 | <BaseControl |
| 204 | label={ __( 'Color' ) } |
| 205 | > |
| 206 | <ColorPalette |
| 207 | value={ settings.vAxis.minorGridlines ? settings.vAxis.minorGridlines.color : '' } |
| 208 | onChange={ e => { |
| 209 | if ( ! settings.vAxis.minorGridlines ) { |
| 210 | settings.vAxis.minorGridlines = {}; |
| 211 | } |
| 212 | settings.vAxis.minorGridlines.color = e; |
| 213 | this.props.edit( settings ); |
| 214 | } } |
| 215 | /> |
| 216 | </BaseControl> |
| 217 | |
| 218 | </PanelBody> |
| 219 | |
| 220 | <PanelBody |
| 221 | title={ __( 'View Window' ) } |
| 222 | className="visualizer-inner-sections" |
| 223 | initialOpen={ false } |
| 224 | > |
| 225 | |
| 226 | <TextControl |
| 227 | label={ __( 'Maximun Value' ) } |
| 228 | help={ __( 'The maximum vertical data value to render.' ) } |
| 229 | value={ settings.vAxis.viewWindow ? settings.vAxis.viewWindow.max : '' } |
| 230 | onChange={ e => { |
| 231 | if ( ! settings.vAxis.viewWindow ) { |
| 232 | settings.vAxis.viewWindow = {}; |
| 233 | } |
| 234 | settings.vAxis.viewWindow.max = e; |
| 235 | this.props.edit( settings ); |
| 236 | } } |
| 237 | /> |
| 238 | |
| 239 | <TextControl |
| 240 | label={ __( 'Minimum Value' ) } |
| 241 | help={ __( 'The minimum vertical data value to render.' ) } |
| 242 | value={ settings.vAxis.viewWindow ? settings.vAxis.viewWindow.min : '' } |
| 243 | onChange={ e => { |
| 244 | if ( ! settings.vAxis.viewWindow ) { |
| 245 | settings.vAxis.viewWindow = {}; |
| 246 | } |
| 247 | settings.vAxis.viewWindow.min = e; |
| 248 | this.props.edit( settings ); |
| 249 | } } |
| 250 | /> |
| 251 | |
| 252 | </PanelBody> |
| 253 | |
| 254 | </Fragment> |
| 255 | |
| 256 | )} |
| 257 | |
| 258 | </PanelBody> |
| 259 | ); |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | export default VerticalAxisSettings; |
| 264 |