Skip to content

Commit fc075b8

Browse files
author
minjk-bl
committed
Add bins option to Seaborn - histplot
1 parent 358540e commit fc075b8

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

data/m_visualize/seabornLibrary.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ define([
4848
/** Distribution plots */
4949
'histplot': {
5050
name: 'Histogram Plot',
51-
code: '${allocateTo} = sns.histplot(${data}${x}${y}${hue}${etc})',
51+
code: '${allocateTo} = sns.histplot(${data}${x}${y}${hue}${bins}${etc})',
5252
description: 'Plot univariate or bivariate histograms to show distributions of datasets.',
5353
options: [
5454
{ name: 'data', component: ['var_select'], var_type: ['DataFrame', 'Series', 'list'], usePair: true },
5555
{ name: 'x', component: ['col_select'], usePair: true },
5656
{ name: 'y', component: ['col_select'], usePair: true },
5757
{ name: 'hue', component: ['col_select'], usePair: true },
58+
{ name: 'bins', component: ['col_select'], usePair: true },
5859
{ name: 'allocateTo', label: 'Allocate To', component: ['input'], usePair: true }
5960
]
6061
},

html/m_visualize/seaborn.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,18 @@
8888
</select>
8989
</div>
9090
</div>
91-
<label for="hue" class="vp-bold">Hue</label>
92-
<select id="hue" class="vp-select vp-state">
93-
94-
</select>
91+
<div class="vp-grid-col-p50">
92+
<div class="vp-grid-box">
93+
<label for="hue" class="vp-bold">Hue</label>
94+
<select id="hue" class="vp-select vp-state">
95+
96+
</select>
97+
</div>
98+
<div class="vp-grid-box sb-option bins">
99+
<label for="bins" class="vp-bold">Bins</label>
100+
<input type="text" class="vp-input vp-state" id="bins" placeholder="Type bins" />
101+
</div>
102+
</div>
95103
<label for="userOption" class="vp-bold">User Option</label>
96104
<input type="text" id="userOption" class="vp-input vp-state wp100" placeholder="key=value, ..."/>
97105
</div>

js/m_visualize/Seaborn.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,15 @@ define([
157157
$(that.wrapSelector(com_util.formatString('.vp-tab-page-box.{0} > .vp-tab-page', level))).hide();
158158
$(that.wrapSelector(com_util.formatString('.vp-tab-page[data-type="{0}"]', type))).show();
159159
});
160+
161+
$(this.wrapSelector('#chartType')).on('change', function() {
162+
// add bins to histplot
163+
let chartType = $(this).val();
164+
$(that.wrapSelector('.sb-option')).hide();
165+
if (chartType == 'histplot') {
166+
$(that.wrapSelector('.sb-option.bins')).show();
167+
}
168+
})
160169

161170
// use data or not
162171
$(this.wrapSelector('#setXY')).on('change', function() {
@@ -311,6 +320,12 @@ define([
311320
});
312321
$(page).find('#sampleCount').html(sampleCountTag.toString());
313322

323+
// data options depend on chart type
324+
$(page).find('.sb-option').hide();
325+
if (this.state.chartType == 'histplot') {
326+
$(page).find('.sb-option.bins').show();
327+
}
328+
314329
//================================================================
315330
// Load state
316331
//================================================================

0 commit comments

Comments
 (0)