@@ -4,7 +4,7 @@ import {get, isEmpty} from 'lodash';
4
4
5
5
import { dispatchChartUpdate , dispatchChartFilterSelection , dispatchChartSelect , getChartData , dispatchSetActiveTrace , dispatchChartExpanded } from '../ChartsCntlr.js' ;
6
6
import { SimpleComponent } from '../../ui/SimpleComponent.jsx' ;
7
- import { getTblById , clearFilters , getColumnIdx } from '../../tables/TableUtil.js' ;
7
+ import { getTblById , clearFilters , getColumnIdx , getColumnType } from '../../tables/TableUtil.js' ;
8
8
import { dispatchSetLayoutMode , LO_MODE , LO_VIEW } from '../../core/LayoutCntlr.js' ;
9
9
import { downloadChart } from './PlotlyWrapper.jsx' ;
10
10
@@ -45,29 +45,36 @@ export class ScatterToolbar extends SimpleComponent {
45
45
}
46
46
}
47
47
48
- function isSelectable ( tbl_id , chartId , type , activeTrace ) {
49
- const typeWithX = [ 'heatmap' , 'histogram2dcontour' , 'histogram2d' ] ;
50
- const typeWithY = [ 'heatmap' , 'histogram2dcontour' , 'histogram2d' ] ;
48
+ function isSelectable ( tbl_id , chartId , type ) {
49
+ const typeWithX = [ 'heatmap' , 'histogram2dcontour' , 'histogram2d' , 'scatter' ] ;
50
+ const typeWithY = [ 'heatmap' , 'histogram2dcontour' , 'histogram2d' , 'scatter' ] ;
51
51
52
52
if ( ! tbl_id ) return false ;
53
+
53
54
const checkX = typeWithX . includes ( type ) ;
54
55
const checkY = typeWithY . includes ( type ) ;
55
-
56
56
if ( ! checkX && ! checkY ) return false ; // chart type has no selection box in tool bar
57
57
58
- const { x, y} = get ( getChartData ( chartId ) , `tablesources.${ activeTrace } .mappings` ) || { } ;
58
+ const { tablesources} = getChartData ( chartId ) ;
59
+ const strCol = [ 'str' , 's' , 'char' , 'c' ] ;
59
60
const tableModel = getTblById ( tbl_id ) ;
60
- const dataExp = [ x , y ] ;
61
-
62
- const noSelectionIdx = [ checkX , checkY ] . findIndex ( ( checkItem , idx ) => {
63
- if ( ! checkItem ) return false ; // ignore
64
- if ( dataExp [ idx ] ) {
65
- return getColumnIdx ( tableModel , dataExp [ idx ] ) < 0 ;
66
- } else {
67
- return true ; // not qualified to have selection box
68
- }
61
+ const noSelectionTraceIdx = tablesources . findIndex ( ( tablesource ) => {
62
+ const { x, y} = get ( tablesource , 'mappings' ) || { } ;
63
+ const dataExp = [ x , y ] ;
64
+
65
+ const noSelectionIdx = [ checkX , checkY ] . findIndex ( ( checkItem , idx ) => {
66
+ if ( ! checkItem ) return false ; // ignore
67
+
68
+ if ( dataExp [ idx ] ) {
69
+ return getColumnIdx ( tableModel , dataExp [ idx ] ) < 0 ||
70
+ strCol . includes ( getColumnType ( tableModel , dataExp [ idx ] ) ) ;
71
+ } else {
72
+ return true ; // not qualified to have selection box
73
+ }
74
+ } ) ;
75
+ return noSelectionIdx >= 0 ;
69
76
} ) ;
70
- return ( noSelectionIdx < 0 ) ;
77
+ return ( noSelectionTraceIdx < 0 ) ;
71
78
}
72
79
73
80
export class BasicToolbar extends SimpleComponent {
@@ -83,7 +90,7 @@ export class BasicToolbar extends SimpleComponent {
83
90
const { activeTrace, hasFilter, hasSelection, tbl_id, dragmode} = this . state ;
84
91
85
92
const type = get ( getChartData ( chartId ) , `data.${ activeTrace } .type` , '' ) ;
86
- const showSelectionPart = isSelectable ( tbl_id , chartId , type , activeTrace ) ;
93
+ const showSelectionPart = isSelectable ( tbl_id , chartId , type ) ;
87
94
const showDragPart = ! type . includes ( 'pie' ) ;
88
95
const is3d = type . endsWith ( '3d' ) || type === 'surface' ; // scatter3d, mesh3d, surface
89
96
0 commit comments