-
-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathPandasPlot.js
More file actions
80 lines (69 loc) · 2.85 KB
/
Copy pathPandasPlot.js
File metadata and controls
80 lines (69 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Project Name : Visual Python
* Description : GUI-based Python code generator
* File Name : PandasPlot.js
* Author : Black Logic
* Note : Library Component
* License : GNU GPLv3 with Visual Python special exception
* Date : 2022. 06. 22
* Change Date :
*/
//============================================================================
// [CLASS] PandasPlot
//============================================================================
define([
'vp_base/js/com/component/LibraryComponent',
'vp_base/js/com/component/DataSelector',
'vp_base/js/com/com_util'
], function(LibraryComponent, DataSelector, com_util) {
/**
* PandasPlot
*/
class PandasPlot extends LibraryComponent {
_init() {
super._init();
this.state = {
i0: '',
o0: '',
figWidth: '',
figHeight: '',
...this.state
}
}
_bindEventAfterRender() {
let that = this;
$(this.wrapSelector('#figWidth')).on('blur', function() {
let width = $(this).val();
let height = $(that.wrapSelector('#figHeight')).val();
if (width !== '' || height !== '') {
$(that.wrapSelector('#figsize')).val(com_util.formatString('({0},{1})', width, height));
} else {
$(that.wrapSelector('#figsize')).val('');
}
});
$(this.wrapSelector('#figHeight')).on('blur', function() {
let width = $(that.wrapSelector('#figWidth')).val();
let height = $(this).val();
if (width !== '' || height !== '') {
$(that.wrapSelector('#figsize')).val(com_util.formatString('({0},{1})', width, height));
} else {
$(that.wrapSelector('#figsize')).val('');
}
});
}
render() {
super.render();
// add data selector
let dataSelector = new DataSelector({ pageThis: this, id: 'i0', value: this.state.i0, required: true });
$(this.wrapSelector('#i0')).replaceWith(dataSelector.toTagString());
// divide figure size option to width / height
let figSizeTemplate = `
<input type="number" class="vp-input m vp-state" id="figWidth" placeholder="Width" value="${this.state.figWidth}"/>
<input type="number" class="vp-input m vp-state" id="figHeight" placeholder="Height" value="${this.state.figHeight}"/>`
$(this.wrapSelector('#figsize')).hide();
$(this.wrapSelector('#figsize')).parent().append(figSizeTemplate);
this._bindEventAfterRender();
}
}
return PandasPlot;
});