Skip to content

Commit 7111cc5

Browse files
author
minjk-bl
committed
Seaborn - add Select option... as empty option
1 parent 0413293 commit 7111cc5

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

html/m_visualize/seaborn.html

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@
110110

111111
<label for="useLegend" class="vp-bold">Legend</label>
112112
<div class="vp-grid-col-p50">
113-
<select id="useLegend" class="vp-select vp-state">
114-
<option value="False">False</option>
115-
<option value="True">True</option>
116-
</select>
117113
<select id="legendPos" class="vp-select vp-state">
118114
<!-- Legend Position FIXME: -->
119115

@@ -124,15 +120,12 @@
124120
<!-- STYLE: grid / marker / color -->
125121
<label for="useGrid" class="vp-bold">Grid</label>
126122
<select id="useGrid" class="vp-select vp-state">
127-
<option value="False">False</option>
123+
<option value="">Select option...</option>
128124
<option value="True">True</option>
125+
<option value="False">False</option>
129126
</select>
130127
<label for="useMarker" class="vp-bold">Marker</label>
131128
<div class="vp-grid-col-p50">
132-
<select id="useMarker" class="vp-select vp-state">
133-
<option value="False">False</option>
134-
<option value="True">True</option>
135-
</select>
136129
<select id="markerStyle" class="vp-select vp-state">
137130
<!-- TODO: -->
138131
<option></option>

js/m_visualize/Seaborn.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,9 @@ define([
4848
title: '',
4949
x_label: '',
5050
y_label: '',
51-
useLegend: 'False',
5251
legendPos: '',
5352
// style options
5453
useGrid: 'False',
55-
useMarker: 'False',
5654
markerStyle: '',
5755
// setting options
5856
x_limit_from: '',
@@ -75,13 +73,22 @@ define([
7573
}
7674

7775
this.legendPosList = [
78-
'best', 'upper right', 'upper left', 'lower left', 'lower right',
79-
'center left', 'center right', 'lower center', 'upper center', 'center'
76+
{label: 'Select option...', value: ''},
77+
{label: 'best', value: 'best'},
78+
{label: 'upper right', value: 'upper right'},
79+
{label: 'upper left', value: 'upper left'},
80+
{label: 'lower left', value: 'lower left'},
81+
{label: 'lower right', value: 'lower right'},
82+
{label: 'center left', value: 'center left'},
83+
{label: 'center right', value: 'center right'},
84+
{label: 'lower center', value: 'lower center'},
85+
{label: 'upper center', value: 'upper center'},
86+
{label: 'center', value: 'center'},
8087
];
8188

8289
this.markerList = [
8390
// 'custom': { label: 'Custom', value: 'marker' },
84-
{ label: ' ', value: ' ', title: 'select marker style'},
91+
{ label: 'Select option...', value: '', title: 'select marker style'},
8592
{ label: '.', value: '.', title: 'point' },
8693
{ label: ',', value: ',', title: 'pixel' },
8794
{ label: 'o', value: 'o', title: 'circle' },
@@ -259,11 +266,11 @@ define([
259266
let legendPosTag = new com_String();
260267
this.legendPosList.forEach(pos => {
261268
let selectedFlag = '';
262-
if (pos == that.state.legendPos) {
269+
if (pos.value == that.state.legendPos) {
263270
selectedFlag = 'selected';
264271
}
265272
legendPosTag.appendFormatLine('<option value="{0}" {1}>{2}{3}</option>',
266-
pos, selectedFlag, pos, pos == 'best'?' (default)':'');
273+
pos.value, selectedFlag, pos.label, pos.value == 'best'?' (default)':'');
267274
});
268275
$(page).find('#legendPos').html(legendPosTag.toString());
269276

@@ -514,8 +521,8 @@ define([
514521
generateCode(preview=false) {
515522
let {
516523
chartType, data, userOption='',
517-
title, x_label, y_label, useLegend, legendPos,
518-
useGrid, useMarker, markerStyle,
524+
title, x_label, y_label, legendPos,
525+
useGrid, markerStyle,
519526
x_limit_from, x_limit_to, y_limit_from, y_limit_to,
520527
useSampling, sampleCount
521528
} = this.state;
@@ -528,7 +535,7 @@ define([
528535
let chartCode = new com_String();
529536

530537
let etcOptionCode = []
531-
if (useMarker == 'True') {
538+
if (markerStyle != '') {
532539
// TODO: marker to seaborn argument (ex. marker='+' / markers={'Lunch':'s', 'Dinner':'X'})
533540
etcOptionCode.push(com_util.formatString("marker='{0}'", markerStyle));
534541
}
@@ -563,11 +570,11 @@ define([
563570
if (y_limit_from != '' && y_limit_to != '') {
564571
chartCode.appendFormatLine("plt.ylim(({0}, {1}))", y_limit_from, y_limit_to);
565572
}
566-
if (useLegend == 'True' && legendPos != '') {
573+
if (legendPos != '') {
567574
chartCode.appendFormatLine("plt.legend(loc='{0}')", legendPos);
568575
}
569-
if (useGrid == 'True') {
570-
chartCode.appendLine("plt.grid(True)");
576+
if (useGrid != '') {
577+
chartCode.appendFormatLine("plt.grid({0})", useGrid);
571578
// TODO: grid types
572579
// plt.grid(True, axis='x', color='red', alpha=0.5, linestyle='--')
573580
}

0 commit comments

Comments
 (0)