@@ -50,14 +50,15 @@ define([
50
50
super . _init ( ) ;
51
51
52
52
this . prop = {
53
- type : 'data' , // selector type : data / column
53
+ type : 'data' , // selector type : data / column / ml
54
54
pageThis : null , // target's page object
55
55
id : '' , // target id
56
56
value : null , // pre-defined value
57
57
withPopup : true , // with filter button to show simple subset popup
58
58
finish : null , // callback after selection (value, dtype)
59
59
select : null , // callback after selection from suggestInput (value, dtype)
60
60
allowDataType : null , // list of allowed data types
61
+ dataCategory : null , // list of data category (use it for ml categories)
61
62
// additional options
62
63
boxClasses : '' ,
63
64
classes : '' ,
@@ -71,9 +72,20 @@ define([
71
72
// If null, define default allow data type
72
73
if ( ! this . prop . allowDataType ) {
73
74
// default allow data types
74
- this . prop . allowDataType = [
75
- 'DataFrame' , 'Series' , 'ndarray' , 'list' , 'dict'
76
- ]
75
+ if ( this . prop . type === 'ml' ) {
76
+ this . prop . allowDataType = vpConfig . getMLDataTypes ( ) ;
77
+ } else {
78
+ this . prop . allowDataType = [
79
+ 'DataFrame' , 'Series' , 'ndarray' , 'list' , 'dict'
80
+ ]
81
+ }
82
+ }
83
+ if ( ! this . prop . dataCategory ) {
84
+ if ( this . prop . type === 'ml' ) {
85
+ this . prop . dataCategory = vpConfig . getMLCategories ( ) ;
86
+ } else {
87
+ this . prop . dataCategory = this . prop . allowDataType ;
88
+ }
77
89
}
78
90
79
91
this . state = {
@@ -282,7 +294,11 @@ define([
282
294
that . renderVariableBox ( that . _varList . filter ( obj => ! that . prop . allowDataType . includes ( obj . dtype ) ) ) ;
283
295
} else {
284
296
// filter variable list
285
- that . renderVariableBox ( that . _varList . filter ( obj => obj . dtype == type ) ) ;
297
+ if ( that . prop . type === 'ml' ) {
298
+ that . renderVariableBox ( that . _varList . filter ( obj => vpConfig . getMLDataDict ( type ) . includes ( obj . dtype ) ) ) ;
299
+ } else {
300
+ that . renderVariableBox ( that . _varList . filter ( obj => obj . dtype == type ) ) ;
301
+ }
286
302
}
287
303
288
304
} ) ;
@@ -530,7 +546,7 @@ define([
530
546
let varTags = new com_String ( ) ;
531
547
let types = [
532
548
'All' ,
533
- ...this . prop . allowDataType ,
549
+ ...this . prop . dataCategory ,
534
550
'Others'
535
551
] ;
536
552
// Add Data Types to filter
@@ -551,10 +567,17 @@ define([
551
567
let that = this ;
552
568
let varTags = new com_String ( ) ;
553
569
varTags = new com_String ( ) ;
554
- varList && varList . forEach ( ( obj , idx ) => {
555
- varTags . appendFormatLine ( '<div class="{0} {1}" title="{2}" data-type="{3}">{4}</div>'
556
- , 'vp-ds-var-item' , ( that . state . data == obj . value ?'selected' :'' ) , obj . dtype , obj . dtype , obj . label ) ;
557
- } ) ;
570
+ if ( this . prop . type === 'ml' ) {
571
+ varList && varList . forEach ( ( obj , idx ) => {
572
+ varTags . appendFormatLine ( '<div class="{0} {1}" title="{2}" data-type="{3}">{4}<span class="vp-gray-text"> | {5}</span></div>'
573
+ , 'vp-ds-var-item' , ( that . state . data == obj . value ?'selected' :'' ) , obj . dtype , obj . dtype , obj . label , obj . dtype ) ;
574
+ } ) ;
575
+ } else {
576
+ varList && varList . forEach ( ( obj , idx ) => {
577
+ varTags . appendFormatLine ( '<div class="{0} {1}" title="{2}" data-type="{3}">{4}</div>'
578
+ , 'vp-ds-var-item' , ( that . state . data == obj . value ?'selected' :'' ) , obj . dtype , obj . dtype , obj . label ) ;
579
+ } ) ;
580
+ }
558
581
$ ( this . wrapSelector ( '.vp-ds-variable-box' ) ) . html ( varTags . toString ( ) ) ;
559
582
560
583
// focus on selected item
0 commit comments