visualizer
/
classes
/
Visualizer
/
Gutenberg
/
src
/
Components
/
Sidebar
/
HorizontalAxisSettings.js
HorizontalAxisSettings.js in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.9.4, 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.blockEditor || wp.editor; |
| 12 | |
| 13 | const { |
| 14 | BaseControl, |
| 15 | ExternalLink, |
| 16 | PanelBody, |
| 17 | SelectControl, |
| 18 | TextControl |
| 19 | } = wp.components; |
| 20 | |
| 21 | import { getColorCode } from '../../utils.js'; |
| 22 | |
| 23 | class HorizontalAxisSettings extends Component { |
| 24 | constructor() { |
| 25 | super( ...arguments ); |
| 26 | } |
| 27 | |
| 28 | render() { |
| 29 | |
| 30 | const type = this.props.chart['visualizer-chart-type']; |
| 31 | |
| 32 | const settings = this.props.chart['visualizer-settings']; |
| 33 | |
| 34 | return ( |
| 35 | <PanelBody |
| 36 | title={ __( 'Horizontal Axis Settings' ) } |
| 37 | initialOpen={ false } |
| 38 | className="visualizer-advanced-panel" |
| 39 | > |
| 40 | |
| 41 | <PanelBody |
| 42 | title={ __( 'General Settings' ) } |
| 43 | className="visualizer-inner-sections" |
| 44 | initialOpen={ false } |
| 45 | > |
| 46 | |
| 47 | <TextControl |
| 48 | label={ __( 'Axis Title' ) } |
| 49 | help={ __( 'The title of the horizontal axis.' ) } |
| 50 | value={ settings.hAxis.title } |
| 51 | onChange={ e => { |
| 52 | settings.hAxis.title = e; |
| 53 | this.props.edit( settings ); |
| 54 | } } |
| 55 | /> |
| 56 | |
| 57 | <SelectControl |
| 58 | label={ __( 'Text Position' ) } |
| 59 | help={ __( 'Position of the horizontal axis text, relative to the chart area.' ) } |
| 60 | value={ settings.hAxis.textPosition ? settings.hAxis.textPosition : 'out' } |
| 61 | options={ [ |
| 62 | { label: __( 'Inside the chart' ), value: 'in' }, |
| 63 | { label: __( 'Outside the chart' ), value: 'out' }, |
| 64 | { label: __( 'None' ), value: 'none' } |
| 65 | ] } |
| 66 | onChange={ e => { |
| 67 | settings.hAxis.textPosition = e; |
| 68 | this.props.edit( settings ); |
| 69 | } } |
| 70 | /> |
| 71 | |
| 72 | <SelectControl |
| 73 | label={ __( 'Direction' ) } |
| 74 | help={ __( 'The direction in which the values along the horizontal axis grow.' ) } |
| 75 | value={ settings.hAxis.direction ? settings.hAxis.direction : '1' } |
| 76 | options={ [ |
| 77 | { label: __( 'Identical Direction' ), value: '1' }, |
| 78 | { label: __( 'Reverse Direction' ), value: '-1' } |
| 79 | ] } |
| 80 | onChange={ e => { |
| 81 | settings.hAxis.direction = e; |
| 82 | this.props.edit( settings ); |
| 83 | } } |
| 84 | /> |
| 85 | |
| 86 | <BaseControl |
| 87 | label={ __( 'Base Line Color' ) } |
| 88 | > |
| 89 | <ColorPalette |
| 90 | value={ settings.vAxis.baselineColor } |
| 91 | onChange={ e => { |
| 92 | settings.vAxis.baselineColor = getColorCode( e ); |
| 93 | this.props.edit( settings ); |
| 94 | } } |
| 95 | /> |
| 96 | </BaseControl> |
| 97 | |
| 98 | <BaseControl |
| 99 | label={ __( 'Axis Text Color' ) } |
| 100 | > |
| 101 | <ColorPalette |
| 102 | value={ settings.hAxis.textStyle.color || settings.hAxis.textStyle } |
| 103 | onChange={ e => { |
| 104 | settings.hAxis.textStyle = {}; |
| 105 | settings.hAxis.textStyle.color = getColorCode( e ); |
| 106 | this.props.edit( settings ); |
| 107 | } } |
| 108 | /> |
| 109 | </BaseControl> |
| 110 | |
| 111 | { ( -1 >= [ 'column' ].indexOf( type ) ) && ( |
| 112 | <Fragment> |
| 113 | <TextControl |
| 114 | label={ __( 'Number Format' ) } |
| 115 | help={ __( 'Enter custom format pattern to apply to horizontal axis labels.' ) } |
| 116 | value={ settings.hAxis.format } |
| 117 | onChange={ e => { |
| 118 | settings.hAxis.format = e; |
| 119 | this.props.edit( settings ); |
| 120 | } } |
| 121 | /> |
| 122 | |
| 123 | <p> |
| 124 | { __( 'For number axis labels, this is a subset of the formatting ' ) } |
| 125 | <ExternalLink href="http://icu-project.org/apiref/icu4c/classDecimalFormat.html#_details"> |
| 126 | { __( 'ICU pattern set.' ) } |
| 127 | </ExternalLink> |
| 128 | { __( ' 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.' ) } |
| 129 | </p> |
| 130 | |
| 131 | <p> |
| 132 | { __( 'For date axis labels, this is a subset of the date formatting ' ) } |
| 133 | <ExternalLink href="https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax"> |
| 134 | { __( 'ICU date and time format.' ) } |
| 135 | </ExternalLink> |
| 136 | </p> |
| 137 | </Fragment> |
| 138 | ) } |
| 139 | |
| 140 | </PanelBody> |
| 141 | |
| 142 | { ( -1 >= [ 'column' ].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 horizontal 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.hAxis.gridlines ? settings.hAxis.gridlines.count : '' } |
| 156 | onChange={ e => { |
| 157 | if ( ! settings.hAxis.gridlines ) { |
| 158 | settings.hAxis.gridlines = {}; |
| 159 | } |
| 160 | |
| 161 | settings.hAxis.gridlines.count = e; |
| 162 | this.props.edit( settings ); |
| 163 | } } |
| 164 | /> |
| 165 | |
| 166 | <BaseControl |
| 167 | label={ __( 'Color' ) } |
| 168 | > |
| 169 | <ColorPalette |
| 170 | value={ settings.hAxis.gridlines ? settings.hAxis.gridlines.color : '' } |
| 171 | onChange={ e => { |
| 172 | if ( ! settings.hAxis.gridlines ) { |
| 173 | settings.hAxis.gridlines = {}; |
| 174 | } |
| 175 | |
| 176 | settings.hAxis.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.hAxis.minorGridlines ? settings.hAxis.minorGridlines.count : '' } |
| 194 | onChange={ e => { |
| 195 | if ( ! settings.hAxis.minorGridlines ) { |
| 196 | settings.hAxis.minorGridlines = {}; |
| 197 | } |
| 198 | settings.hAxis.minorGridlines.count = e; |
| 199 | this.props.edit( settings ); |
| 200 | } } |
| 201 | /> |
| 202 | |
| 203 | <BaseControl |
| 204 | label={ __( 'Color' ) } |
| 205 | > |
| 206 | <ColorPalette |
| 207 | value={ settings.hAxis.minorGridlines ? settings.hAxis.minorGridlines.color : '' } |
| 208 | onChange={ e => { |
| 209 | if ( ! settings.hAxis.minorGridlines ) { |
| 210 | settings.hAxis.minorGridlines = {}; |
| 211 | } |
| 212 | settings.hAxis.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.hAxis.viewWindow ? settings.hAxis.viewWindow.max : '' } |
| 230 | onChange={ e => { |
| 231 | if ( ! settings.hAxis.viewWindow ) { |
| 232 | settings.hAxis.viewWindow = {}; |
| 233 | } |
| 234 | settings.hAxis.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.hAxis.viewWindow ? settings.hAxis.viewWindow.min : '' } |
| 243 | onChange={ e => { |
| 244 | if ( ! settings.hAxis.viewWindow ) { |
| 245 | settings.hAxis.viewWindow = {}; |
| 246 | } |
| 247 | settings.hAxis.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 HorizontalAxisSettings; |
| 264 |