Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit62255d4

Browse files
author
minjk-bl
committed
Fixed Load/Save operation for WordCloud
1 parent5571ddc commit62255d4

File tree

3 files changed

+48
-14
lines changed

3 files changed

+48
-14
lines changed

‎html/m_visualize/wordCloud.html‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
</div>
2525

2626
<labelfor="wordCount"class="vp-bold">Number of words</label>
27-
<inputtype="number"id="wordCount"class="vp-input vp-state"min="0"value="200"/>
27+
<inputtype="number"id="wordCount"class="vp-input vp-state"min="0"/>
2828

2929
</div>
3030
<divclass="vp-tab-page vp-grid-box"data-type="wordcloud"style="display: none;">
@@ -40,8 +40,8 @@
4040
<divclass="vp-tab-page vp-grid-box"data-type="plot"style="display: none;">
4141
<labelfor="figWidth"class="vp-bold">Figure size</label>
4242
<div>
43-
<inputtype="number"id="figWidth"class="vp-input vp-state"min="0"value="8"placeholder="Width"/>
44-
<inputtype="number"id="figHeight"class="vp-input vp-state"min="0"value="20"placeholder="Height"/>
43+
<inputtype="number"id="figWidth"class="vp-input vp-state"min="0"placeholder="Width"/>
44+
<inputtype="number"id="figHeight"class="vp-input vp-state"min="0"placeholder="Height"/>
4545
</div>
4646
</div>
4747
</div>

‎js/com/component/DataSelector.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ define([
185185
that.state.dataType=ui.item.dtype;
186186
that.state.returnDataType=ui.item.dtype;
187187

188-
//that.prop.pageThis.state[that.prop.id + '_state'] = that.state;
188+
that.prop.pageThis.state[that.prop.id+'_state']=that.state;
189189

190190
$(this).trigger('change');
191191

‎js/m_visualize/WordCloud.js‎

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ define([
3636
data:'',
3737
useFile:false,
3838
encoding:'',
39-
wordCount:200,
39+
wordCount:'200',
4040
stopWords:'',
4141
fontPath:'',
4242
userOption:'',
@@ -103,6 +103,37 @@ define([
103103
$(page).find('.vp-wc-file-option').hide();
104104
}
105105

106+
letthat=this;
107+
//================================================================
108+
// Load state
109+
//================================================================
110+
Object.keys(this.state).forEach(key=>{
111+
lettag=$(page).find('#'+key);
112+
lettagName=$(tag).prop('tagName');// returns with UpperCase
113+
letvalue=that.state[key];
114+
if(value==undefined){
115+
return;
116+
}
117+
switch(tagName){
118+
case'INPUT':
119+
letinputType=$(tag).prop('type');
120+
if(inputType=='text'||inputType=='number'||inputType=='hidden'){
121+
$(tag).val(value);
122+
break;
123+
}
124+
if(inputType=='checkbox'){
125+
$(tag).prop('checked',value);
126+
break;
127+
}
128+
break;
129+
case'TEXTAREA':
130+
case'SELECT':
131+
default:
132+
$(tag).val(value);
133+
break;
134+
}
135+
});
136+
106137
returnpage;
107138
}
108139

@@ -120,7 +151,7 @@ define([
120151
'height':'200px'
121152
});
122153

123-
//FIXME:bind dataSelector to #data
154+
// bind dataSelector to #data
124155
letdataSelector=newDataSelector({
125156
type:'data',
126157
pageThis:this,
@@ -132,8 +163,6 @@ define([
132163
finish:function(){
133164
that.state.useFile=false;
134165
$(that.wrapSelector('.vp-wc-file-option')).hide();
135-
136-
$(that.wrapSelector('#data')).change();
137166
}
138167
});
139168
$(this.wrapSelector('#data')).replaceWith(dataSelector.toTagString());
@@ -239,7 +268,7 @@ define([
239268

240269
generateCode(preview=false){
241270
let{
242-
data, useFile, encoding, wordCount,
271+
data,data_state,useFile, encoding, wordCount,
243272
stopWords, fontPath, userOption, figWidth, figHeight
244273
}=this.state;
245274
letcode=newcom_String();
@@ -263,11 +292,16 @@ define([
263292
code.appendLine(" word_cloud_text = fp.read()");
264293
code.appendLine();
265294
dataVariable='word_cloud_text';
266-
}
267-
// check data type and convert it to string
268-
letdataType=$(this.wrapSelector('#data')).data('type');
269-
if(dataType=='DataFrame'||dataType=='Series'){
270-
dataVariable=data+'.to_string()';
295+
}else{
296+
// check data type and convert it to string
297+
// let dataType = $(this.wrapSelector('#data')).data('type');
298+
letdataType='';
299+
if(data_state){
300+
dataType=data_state['returnDataType'];
301+
}
302+
if(dataType=='DataFrame'||dataType=='Series'){
303+
dataVariable=data+'.to_string()';
304+
}
271305
}
272306
code.appendFormatLine("counts = Counter({0}.split())",dataVariable);
273307
code.appendFormatLine("tags = counts.most_common({0})",wordCount);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp