Skip to content

Commit a9304f4

Browse files
author
minjk-bl
committed
Add empty option for x, y, hue
1 parent afd7316 commit a9304f4

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

html/m_visualize/seaborn.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@
120120
</div>
121121
<div class="vp-tab-page vp-grid-box" data-type="style" style="display: none;">
122122
<!-- STYLE: grid / marker / color -->
123-
<div class="vp-italic">
124-
<span class="vp-orange-text">STYLE: </span> grid / marker / color
125-
</div>
126123
<label for="useGrid" class="vp-bold">Grid</label>
127124
<select id="useGrid" class="vp-select vp-state">
128125
<option value="False">False</option>

js/com/com_generatorV2.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -656,12 +656,13 @@ define([
656656
* @param {object} target
657657
* @param {array} columnInputIdList
658658
* @param {string} tagType input / select (tag type)
659+
* @param {array/boolean} columnWithEmpty boolean array or value to decide whether select tag has empty space
659660
* Usage :
660661
* $(document).on('change', this.wrapSelector('#dataframe_tag_id'), function() {
661-
* pdGen.vp_bindColumnSource(that.wrapSelector(), this, ['column_input_id']);
662+
* pdGen.vp_bindColumnSource(that.wrapSelector(), this, ['column_input_id'], 'select', [true, true, true]);
662663
* });
663664
*/
664-
var vp_bindColumnSource = function(selector, target, columnInputIdList, tagType="input") {
665+
var vp_bindColumnSource = function(selector, target, columnInputIdList, tagType="input", columnWithEmpty=false) {
665666
var varName = '';
666667
if ($(target).length > 0) {
667668
varName = $(target).val();
@@ -701,8 +702,22 @@ define([
701702
let { result, type, msg } = resultObj;
702703
var varResult = JSON.parse(result);
703704

705+
// check if it needs to add empty option
706+
let addEmpty = false;
707+
if (Array.isArray(columnWithEmpty)) {
708+
addEmpty = columnWithEmpty[idx];
709+
} else {
710+
addEmpty = columnWithEmpty;
711+
}
712+
if (addEmpty == true) {
713+
varResult = [
714+
{value: '', label: ''},
715+
...varResult
716+
]
717+
}
718+
704719
// columns using suggestInput
705-
columnInputIdList && columnInputIdList.forEach(columnInputId => {
720+
columnInputIdList && columnInputIdList.forEach((columnInputId, idx) => {
706721
let defaultValue = $(selector + ' #' + columnInputId).val();
707722
if (defaultValue == null || defaultValue == undefined) {
708723
defaultValue = '';
@@ -724,6 +739,7 @@ define([
724739
'id': columnInputId,
725740
'class': 'vp-select vp-state'
726741
});
742+
// make tag
727743
varResult.forEach(listVar => {
728744
var option = document.createElement('option');
729745
$(option).attr({

js/m_visualize/Seaborn.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ define([
6969
this.chartConfig = CHART_LIBRARIES;
7070
this.chartTypeList = {
7171
'Relational': [ 'scatterplot', 'lineplot' ],
72-
'Distributions': [ 'histplot', 'kdeplot', 'ecdfplot', 'rugplot' ], // FIXME: ecdf : no module
72+
'Distributions': [ 'histplot', 'kdeplot', 'rugplot' ],
7373
'Categorical': [ 'stripplot', 'swarmplot', 'boxplot', 'violinplot', 'pointplot', 'barplot' ],
74-
'ETC': [ ]
74+
// 'ETC': [ ]
7575
}
7676
}
7777

@@ -212,7 +212,7 @@ define([
212212
$(that.wrapSelector('#hue')).prop('disabled', false);
213213

214214
// bind column source using selected dataframe
215-
com_generator.vp_bindColumnSource(that.wrapSelector(), $(that.wrapSelector('#data')), ['x', 'y', 'hue'], 'select');
215+
com_generator.vp_bindColumnSource(that.wrapSelector(), $(that.wrapSelector('#data')), ['x', 'y', 'hue'], 'select', true);
216216
} else {
217217
$(that.wrapSelector('#x')).prop('disabled', true);
218218
$(that.wrapSelector('#y')).prop('disabled', true);

0 commit comments

Comments
 (0)