@@ -42,7 +42,18 @@ define([
42
42
super . _bindEvent ( ) ;
43
43
44
44
let that = this ;
45
-
45
+ // setting popup - set default
46
+ $ ( this . wrapSelector ( '#setDefault' ) ) . on ( 'change' , function ( ) {
47
+ let checked = $ ( this ) . prop ( 'checked' ) ;
48
+
49
+ if ( checked ) {
50
+ // disable input
51
+ $ ( that . wrapSelector ( '.vp-chart-setting-body input' ) ) . prop ( 'disabled' , true ) ;
52
+ } else {
53
+ // enable input
54
+ $ ( that . wrapSelector ( '.vp-chart-setting-body input' ) ) . prop ( 'disabled' , false ) ;
55
+ }
56
+ } ) ;
46
57
}
47
58
48
59
templateForBody ( ) {
@@ -113,31 +124,40 @@ define([
113
124
generateImportCode ( ) {
114
125
var code = new com_String ( ) ;
115
126
code . appendLine ( 'import matplotlib.pyplot as plt' ) ;
116
- code . append ( 'import seaborn as sns' ) ;
127
+ code . appendLine ( 'import seaborn as sns' ) ;
128
+ code . append ( '%matplotlib inline' ) ;
117
129
return [ code . toString ( ) ] ;
118
130
}
119
131
120
132
generateCode ( ) {
121
133
var code = new com_String ( ) ;
122
134
123
135
// get parameters
124
- let { figureWidth, figureHeight, styleSheet, fontName, fontSize } = this . state ;
125
-
126
- code . appendLine ( 'import matplotlib.pyplot as plt' ) ;
127
- code . appendFormatLine ( "plt.rc('figure', figsize=({0}, {1}))" , figureWidth , figureHeight ) ;
128
- if ( styleSheet && styleSheet . length > 0 ) {
129
- code . appendFormatLine ( "plt.style.use('{0}')" , styleSheet ) ;
130
- }
131
- code . appendLine ( ) ;
132
-
133
- code . appendLine ( 'from matplotlib import rcParams' ) ;
134
- if ( fontName && fontName . length > 0 ) {
135
- code . appendFormatLine ( "rcParams['font.family'] = '{0}'" , fontName ) ;
136
- }
137
- if ( fontSize && fontSize . length > 0 ) {
138
- code . appendFormatLine ( "rcParams['font.size'] = {0}" , fontSize ) ;
136
+ let setDefault = $ ( this . wrapSelector ( '#setDefault' ) ) . prop ( 'checked' ) ;
137
+ if ( setDefault == true ) {
138
+ code . appendLine ( 'from matplotlib import rcParams, rcParamsDefault' ) ;
139
+ code . append ( 'rcParams.update(rcParamsDefault)' ) ;
140
+ } else {
141
+ // get parameters
142
+ let { figureWidth, figureHeight, styleSheet, fontName, fontSize } = this . state ;
143
+
144
+ code . appendLine ( 'import matplotlib.pyplot as plt' ) ;
145
+ code . appendLine ( 'import seaborn as sns' ) ;
146
+ code . appendFormatLine ( "plt.rc('figure', figsize=({0}, {1}))" , figureWidth , figureHeight ) ;
147
+ if ( styleSheet && styleSheet . length > 0 ) {
148
+ code . appendFormatLine ( "plt.style.use('{0}')" , styleSheet ) ;
149
+ }
150
+ code . appendLine ( ) ;
151
+
152
+ code . appendLine ( 'from matplotlib import rcParams' ) ;
153
+ if ( fontName && fontName . length > 0 ) {
154
+ code . appendFormatLine ( "rcParams['font.family'] = '{0}'" , fontName ) ;
155
+ }
156
+ if ( fontSize && fontSize . length > 0 ) {
157
+ code . appendFormatLine ( "rcParams['font.size'] = {0}" , fontSize ) ;
158
+ }
159
+ code . append ( "rcParams['axes.unicode_minus'] = False" ) ;
139
160
}
140
- code . append ( "rcParams['axes.unicode_minus'] = False" ) ;
141
161
142
162
return code . toString ( ) ;
143
163
}
0 commit comments