14
14
//============================================================================
15
15
define ( [
16
16
'vp_base/js/com/component/LibraryComponent' ,
17
- 'vp_base/js/com/component/DataSelector'
18
- ] , function ( LibraryComponent , DataSelector ) {
17
+ 'vp_base/js/com/component/DataSelector' ,
18
+ 'vp_base/js/com/com_util'
19
+ ] , function ( LibraryComponent , DataSelector , com_util ) {
19
20
/**
20
21
* PandasPlot
21
22
*/
@@ -26,15 +27,52 @@ define([
26
27
this . state = {
27
28
i0 : '' ,
28
29
o0 : '' ,
30
+ figWidth : '' ,
31
+ figHeight : '' ,
29
32
...this . state
30
33
}
31
34
}
35
+
36
+ _bindEventAfterRender ( ) {
37
+ let that = this ;
38
+
39
+ $ ( this . wrapSelector ( '#figWidth' ) ) . on ( 'blur' , function ( ) {
40
+ let width = $ ( this ) . val ( ) ;
41
+ let height = $ ( that . wrapSelector ( '#figHeight' ) ) . val ( ) ;
42
+
43
+ if ( width !== '' || height !== '' ) {
44
+ $ ( that . wrapSelector ( '#figsize' ) ) . val ( com_util . formatString ( '({0},{1})' , width , height ) ) ;
45
+ } else {
46
+ $ ( that . wrapSelector ( '#figsize' ) ) . val ( '' ) ;
47
+ }
48
+ } ) ;
49
+ $ ( this . wrapSelector ( '#figHeight' ) ) . on ( 'blur' , function ( ) {
50
+ let width = $ ( that . wrapSelector ( '#figWidth' ) ) . val ( ) ;
51
+ let height = $ ( this ) . val ( ) ;
52
+
53
+ if ( width !== '' || height !== '' ) {
54
+ $ ( that . wrapSelector ( '#figsize' ) ) . val ( com_util . formatString ( '({0},{1})' , width , height ) ) ;
55
+ } else {
56
+ $ ( that . wrapSelector ( '#figsize' ) ) . val ( '' ) ;
57
+ }
58
+ } ) ;
59
+ }
60
+
32
61
render ( ) {
33
62
super . render ( ) ;
34
63
35
64
// add data selector
36
65
let dataSelector = new DataSelector ( { pageThis : this , id : 'i0' , value : this . state . i0 , required : true } ) ;
37
66
$ ( this . wrapSelector ( '#i0' ) ) . replaceWith ( dataSelector . toTagString ( ) ) ;
67
+
68
+ // divide figure size option to width / height
69
+ let figSizeTemplate = `
70
+ <input type="number" class="vp-input m vp-state" id="figWidth" placeholder="Width" value="${ this . state . figWidth } "/>
71
+ <input type="number" class="vp-input m vp-state" id="figHeight" placeholder="Height" value="${ this . state . figHeight } "/>`
72
+ $ ( this . wrapSelector ( '#figsize' ) ) . hide ( ) ;
73
+ $ ( this . wrapSelector ( '#figsize' ) ) . parent ( ) . append ( figSizeTemplate ) ;
74
+
75
+ this . _bindEventAfterRender ( ) ;
38
76
}
39
77
}
40
78
0 commit comments