@@ -18,6 +18,8 @@ import {updateSet} from '../../../util/WebUtil.js';
18
18
import { hideColSelectPopup } from '../ColSelectView.jsx' ;
19
19
import { addColorbarChanges } from '../../dataTypes/FireflyHeatmap.js' ;
20
20
import { getColumnType , getTblById } from '../../../tables/TableUtil.js' ;
21
+ import { getColValStats } from '../../TableStatsCntlr.js' ;
22
+ import { getColValidator } from '../ColumnOrExpression.jsx' ;
21
23
22
24
const fieldProps = { labelWidth : 50 , size : 25 } ;
23
25
const boundariesFieldProps = { labelWidth : 35 , size : 10 } ;
@@ -75,6 +77,21 @@ function hasNoXY(type, tablesource) {
75
77
return ( ! get ( tablesource , [ 'mappings' , 'x' ] ) || ! get ( tablesource , [ 'mappings' , 'y' ] ) ) ;
76
78
}
77
79
80
+
81
+ function isNonNumColumn ( tbl_id , colExp ) {
82
+ const numTypes = [ 'double' , 'd' , 'long' , 'l' , 'int' , 'i' , 'float' , 'f' ] ;
83
+ const colType = getColumnType ( getTblById ( tbl_id ) , colExp ) ;
84
+
85
+ if ( colType ) {
86
+ return ! numTypes . includes ( colType ) ;
87
+ } else {
88
+ const colValidator = getColValidator ( getColValStats ( tbl_id ) ) ;
89
+ const { valid} = colValidator ( colExp ) ;
90
+
91
+ return ! valid ;
92
+ }
93
+ }
94
+
78
95
export class BasicOptions extends SimpleComponent {
79
96
80
97
getNextState ( ) {
@@ -93,8 +110,8 @@ export class BasicOptions extends SimpleComponent {
93
110
const type = get ( data , `${ activeTrace } .type` , 'scatter' ) ;
94
111
const noColor = ! hasMarkerColor ( type ) ;
95
112
const noXY = hasNoXY ( type , tablesource ) ;
96
- const xColType = noXY ? '' : getColumnType ( getTblById ( tbl_id ) , get ( tablesource , [ 'mappings' , 'x' ] , '' ) ) ;
97
- const yColType = noXY ? '' : getColumnType ( getTblById ( tbl_id ) , get ( tablesource , [ 'mappings' , 'y' ] , '' ) ) ;
113
+ const isXNotNumeric = noXY ? undefined : isNonNumColumn ( tbl_id , get ( tablesource , [ 'mappings' , 'x' ] , '' ) ) ;
114
+ const isYNotNumeric = noXY ? undefined : isNonNumColumn ( tbl_id , get ( tablesource , [ 'mappings' , 'y' ] , '' ) ) ;
98
115
const xNoLog = type . includes ( 'histogram' ) ? true : undefined ; // histogram2d or histogram2dcontour
99
116
const yNoLog = type . includes ( 'histogram' ) ? true : undefined ;
100
117
@@ -103,7 +120,7 @@ export class BasicOptions extends SimpleComponent {
103
120
< OptionTopBar { ...{ groupKey, activeTrace, chartId, tbl_id} } />
104
121
< FieldGroup className = 'FieldGroup__vertical' keepState = { false } groupKey = { groupKey }
105
122
reducerFunc = { basicFieldReducer ( { chartId, activeTrace} ) } >
106
- < BasicOptionFields { ...{ activeTrace, groupKey, noColor, noXY, xColType , yColType , xNoLog, yNoLog} } />
123
+ < BasicOptionFields { ...{ activeTrace, groupKey, noColor, noXY, isXNotNumeric , isYNotNumeric , xNoLog, yNoLog} } />
107
124
</ FieldGroup >
108
125
</ div >
109
126
) ;
@@ -304,8 +321,7 @@ export class BasicOptionFields extends Component {
304
321
}
305
322
306
323
render ( ) {
307
- const { activeTrace, groupKey, align= 'vertical' , noColor, noXY, xNoLog, yNoLog, xColType, yColType} = this . props ;
308
- const strT = [ 'str' , 'char' , 's' , 'c' ] ;
324
+ const { activeTrace, groupKey, align= 'vertical' , noColor, noXY, xNoLog, yNoLog, isXNotNumeric, isYNotNumeric} = this . props ;
309
325
310
326
// TODO: need color input field
311
327
const colorFldPath = `data.${ activeTrace } .marker.color` ;
@@ -337,16 +353,16 @@ export class BasicOptionFields extends Component {
337
353
{ ! noXY && < div >
338
354
< ValidationField fieldKey = { 'layout.xaxis.title' } />
339
355
< CheckboxGroupInputField fieldKey = '__xoptions'
340
- options = { xNoLog || strT . includes ( xColType ) ? X_AXIS_OPTIONS_NOLOG : X_AXIS_OPTIONS } />
356
+ options = { xNoLog || isXNotNumeric ? X_AXIS_OPTIONS_NOLOG : X_AXIS_OPTIONS } />
341
357
< br />
342
358
< ValidationField fieldKey = { 'layout.yaxis.title' } />
343
359
< CheckboxGroupInputField fieldKey = '__yoptions'
344
- options = { yNoLog || strT . includes ( yColType ) ? Y_AXIS_OPTIONS_NOLOG : Y_AXIS_OPTIONS } />
360
+ options = { yNoLog || isYNotNumeric ? Y_AXIS_OPTIONS_NOLOG : Y_AXIS_OPTIONS } />
345
361
< br />
346
362
< div style = { helpStyle } >
347
363
Set plot boundaries if different from data range.
348
364
</ div >
349
- { strT . includes ( xColType ) ? false :
365
+ { isXNotNumeric ? false :
350
366
< div style = { { display : 'flex' , flexDirection : 'row' , padding : '5px 15px 0' } } >
351
367
< div style = { { paddingRight : 5 } } >
352
368
< ValidationField fieldKey = { 'fireflyLayout.xaxis.min' } />
@@ -355,7 +371,7 @@ export class BasicOptionFields extends Component {
355
371
< ValidationField fieldKey = { 'fireflyLayout.xaxis.max' } />
356
372
</ div >
357
373
</ div > }
358
- { strT . includes ( yColType ) ? false :
374
+ { isYNotNumeric ? false :
359
375
< div style = { { display : 'flex' , flexDirection : 'row' , padding : '0px 15px 15px' } } >
360
376
< div style = { { paddingRight : 5 } } >
361
377
< ValidationField fieldKey = { 'fireflyLayout.yaxis.min' } />
@@ -396,8 +412,8 @@ BasicOptionFields.propTypes = {
396
412
xNoLog : PropTypes . bool ,
397
413
yNoLog : PropTypes . bool ,
398
414
noXY : PropTypes . bool ,
399
- xColType : PropTypes . string ,
400
- yColType : PropTypes . string
415
+ isXNotNumeric : PropTypes . bool ,
416
+ isYNotNumeric : PropTypes . bool
401
417
} ;
402
418
403
419
0 commit comments