visualizer
/
classes
/
Visualizer
/
Gutenberg
/
src
/
Components
/
Sidebar
/
HorizontalAxisSettings.js
HorizontalAxisSettings.js in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.3.1, at classes/Visualizer/Gutenberg/src/Components/Sidebar/HorizontalAxisSettings.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.editor; |
| 12 | |
| 13 | const { |
| 14 | BaseControl, |
| 15 | ExternalLink, |
| 16 | PanelBody, |
| 17 | SelectControl, |
| 18 | TextControl |
| 19 | } = wp.components; |
| 20 | |
| 21 | class HorizontalAxisSettings 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={ __( 'Horizontal 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 horizontal axis.' ) } |
| 48 | value={ settings.hAxis.title } |
| 49 | onChange={ e => { |
| 50 | settings.hAxis.title = e; |
| 51 | this.props.edit( settings ); |
| 52 | } } |
| 53 | /> |
| 54 | |
| 55 | <SelectControl |
| 56 | label={ __( 'Text Position' ) } |
| 57 | help={ __( 'Position of the horizontal axis text, relative to the chart area.' ) } |
| 58 | value={ settings.hAxis.textPosition ? settings.hAxis.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.hAxis.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 horizontal axis grow.' ) } |
| 73 | value={ settings.hAxis.direction ? settings.hAxis.direction : '1' } |
| 74 | options={ [ |
| 75 | { label: __( 'Identical Direction' ), value: '1' }, |
| 76 | { label: __( 'Reverse Direction' ), value: '-1' } |
| 77 | ] } |
| 78 | onChange={ e => { |
| 79 | settings.hAxis.direction = e; |
| 80 | this.props.edit( settings ); |
| 81 | } } |
| 82 | /> |
| 83 | |
| 84 | <BaseControl |
| 85 | label={ __( 'Base Line Color' ) } |
| 86 | > |
| 87 | <ColorPalette |
| 88 | value={ settings.hAxis.baselineColor } |
| 89 | onChange={ e => { |
| 90 | settings.hAxis.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.hAxis.textStyle.color || settings.hAxis.textStyle } |
| 101 | onChange={ e => { |
| 102 | settings.hAxis.textStyle = {}; |
| 103 | settings.hAxis.textStyle.color = e; |
| 104 | this.props.edit( settings ); |
| 105 | } } |
| 106 | /> |
| 107 | </BaseControl> |
| 108 | |
| 109 | { ( -1 >= [ 'column' ].indexOf( type ) ) && ( |
| 110 | <Fragment> |
| 111 | <TextControl |
| 112 | label={ __( 'Number Format' ) } |
| 113 | help={ __( 'Enter custom format pattern to apply to horizontal axis labels.' ) } |
| 114 | value={ settings.hAxis.format } |
| 115 | onChange={ e => { |
| 116 | settings.hAxis.format = e; |
| 117 | this.props.edit( settings ); |
| 118 | } } |
| 119 | /> |
| 120 | |
| 121 | <p> |
| 122 | { __( 'For number axis labels, this is a subset of the formatting ' ) } |
| 123 | <ExternalLink href="http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details"> |
| 124 | { __( 'ICU pattern set.' ) } |
| 125 | </ExternalLink> |
| 126 | { __( ' 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.' ) } |
| 127 | </p> |
| 128 | |
| 129 | <p> |
| 130 | { __( 'For date axis labels, this is a subset of the date formatting ' ) } |
| 131 | <ExternalLink href="http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax"> |
| 132 | { __( 'ICU date and time format.' ) } |
| 133 | </ExternalLink> |
| 134 | </p> |
| 135 | </Fragment> |
| 136 | ) } |
| 137 | |
| 138 | </PanelBody> |
| 139 | |
| 140 | { ( -1 >= [ 'column' ].indexOf( type ) ) && ( |
| 141 | |
| 142 | <Fragment> |
| 143 | |
| 144 | <PanelBody |
| 145 | title={ __( 'Grid Lines' ) } |
| 146 | className="visualizer-inner-sections" |
| 147 | initialOpen={ false } |
| 148 | > |
| 149 | |
| 150 | <TextControl |
| 151 | label={ __( 'Count' ) } |
| 152 | help={ __( 'The number of horizontal gridlines inside the chart area. Minimum value is 2. Specify -1 to automatically compute the number of gridlines.' ) } |
| 153 | value={ settings.hAxis.gridlines ? settings.hAxis.gridlines.count : '' } |
| 154 | onChange={ e => { |
| 155 | if ( ! settings.hAxis.gridlines ) { |
| 156 | settings.hAxis.gridlines = {}; |
| 157 | } |
| 158 | |
| 159 | settings.hAxis.gridlines.count = e; |
| 160 | this.props.edit( settings ); |
| 161 | } } |
| 162 | /> |
| 163 | |
| 164 | <BaseControl |
| 165 | label={ __( 'Color' ) } |
| 166 | > |
| 167 | <ColorPalette |
| 168 | value={ settings.hAxis.gridlines ? settings.hAxis.gridlines.color : '' } |
| 169 | onChange={ e => { |
| 170 | if ( ! settings.hAxis.gridlines ) { |
| 171 | settings.hAxis.gridlines = {}; |
| 172 | } |
| 173 | |
| 174 | settings.hAxis.gridlines.color = e; |
| 175 | this.props.edit( settings ); |
| 176 | } } |
| 177 | /> |
| 178 | </BaseControl> |
| 179 | |
| 180 | </PanelBody> |
| 181 | |
| 182 | <PanelBody |
| 183 | title={ __( 'Minor Grid Lines' ) } |
| 184 | className="visualizer-inner-sections" |
| 185 | initialOpen={ false } |
| 186 | > |
| 187 | |
| 188 | <TextControl |
| 189 | label={ __( 'Count' ) } |
| 190 | help={ __( 'The number of horizontal minor gridlines between two regular gridlines.' ) } |
| 191 | value={ settings.hAxis.minorGridlines.count } |
| 192 | onChange={ e => { |
| 193 | settings.hAxis.minorGridlines.count = e; |
| 194 | this.props.edit( settings ); |
| 195 | } } |
| 196 | /> |
| 197 | |
| 198 | <BaseControl |
| 199 | label={ __( 'Color' ) } |
| 200 | > |
| 201 | <ColorPalette |
| 202 | value={ settings.hAxis.minorGridlines.color } |
| 203 | onChange={ e => { |
| 204 | settings.hAxis.minorGridlines.color = e; |
| 205 | this.props.edit( settings ); |
| 206 | } } |
| 207 | /> |
| 208 | </BaseControl> |
| 209 | |
| 210 | </PanelBody> |
| 211 | |
| 212 | <PanelBody |
| 213 | title={ __( 'View Window' ) } |
| 214 | className="visualizer-inner-sections" |
| 215 | initialOpen={ false } |
| 216 | > |
| 217 | |
| 218 | <TextControl |
| 219 | label={ __( 'Maximun Value' ) } |
| 220 | help={ __( 'The maximum vertical data value to render.' ) } |
| 221 | value={ settings.hAxis.viewWindow.max } |
| 222 | onChange={ e => { |
| 223 | settings.hAxis.viewWindow.max = e; |
| 224 | this.props.edit( settings ); |
| 225 | } } |
| 226 | /> |
| 227 | |
| 228 | <TextControl |
| 229 | label={ __( 'Minimum Value' ) } |
| 230 | help={ __( 'The minimum vertical data value to render.' ) } |
| 231 | value={ settings.hAxis.viewWindow.min } |
| 232 | onChange={ e => { |
| 233 | settings.hAxis.viewWindow.min = e; |
| 234 | this.props.edit( settings ); |
| 235 | } } |
| 236 | /> |
| 237 | |
| 238 | </PanelBody> |
| 239 | |
| 240 | </Fragment> |
| 241 | |
| 242 | )} |
| 243 | |
| 244 | </PanelBody> |
| 245 | ); |
| 246 | } |
| 247 | } |
| 248 | |
| 249 | export default HorizontalAxisSettings; |
| 250 |