@@ -143,60 +143,115 @@ function getLevelDataPy(data, lang, charts) {
143
143
144
144
// 레벨별 모듈 메소드(lv0~lv3)
145
145
// 레벨별 모듈 메소드(lv0)
146
+ // const level0MethodCountData = [];
147
+ // for (const key in data['py']['level_per_function_method']['level0']) {
148
+ // level0MethodCountData.push(
149
+ // data['py']['level_per_function_method']['level0'][key]
150
+ // );
151
+ // }
152
+ // const level0MethodCountLabels = Object.keys(
153
+ // data['py']['level_per_function_method']['level0']
154
+ // );
146
155
const level0MethodCountData = [ ] ;
147
- for ( const key in data [ 'py' ] [ 'level_per_function_method' ] [ 'level0' ] ) {
148
- level0MethodCountData . push (
149
- data [ 'py' ] [ 'level_per_function_method' ] [ 'level0' ] [ key ]
150
- ) ;
151
- }
152
- const level0MethodCountLabels = Object . keys (
156
+ const level0MethodCountLabels = [ ] ;
157
+
158
+ let sorted = Object . entries (
153
159
data [ 'py' ] [ 'level_per_function_method' ] [ 'level0' ]
154
- ) ;
160
+ ) . sort ( ( a , b ) => b [ 1 ] - a [ 1 ] ) ;
161
+
162
+ for ( let element of sorted ) {
163
+ level0MethodCountLabels . push ( element [ 0 ] ) ;
164
+ level0MethodCountData . push ( element [ 1 ] ) ;
165
+ }
155
166
156
167
// 레벨별 모듈 메소드(lv1)
168
+ // const level1MethodCountData = [];
169
+ // for (const key in data['py']['level_per_function_method']['level1']) {
170
+ // level1MethodCountData.push(
171
+ // data['py']['level_per_function_method']['level1'][key]
172
+ // );
173
+ // }
174
+ // const level1MethodCountLabels = Object.keys(
175
+ // data['py']['level_per_function_method']['level1']
176
+ // );
157
177
const level1MethodCountData = [ ] ;
158
- for ( const key in data [ 'py' ] [ 'level_per_function_method' ] [ 'level1' ] ) {
159
- level1MethodCountData . push (
160
- data [ 'py' ] [ 'level_per_function_method' ] [ 'level1' ] [ key ]
161
- ) ;
162
- }
163
- const level1MethodCountLabels = Object . keys (
178
+ const level1MethodCountLabels = [ ] ;
179
+
180
+ sorted = Object . entries (
164
181
data [ 'py' ] [ 'level_per_function_method' ] [ 'level1' ]
165
- ) ;
182
+ ) . sort ( ( a , b ) => b [ 1 ] - a [ 1 ] ) ;
183
+
184
+ for ( let element of sorted ) {
185
+ level1MethodCountLabels . push ( element [ 0 ] ) ;
186
+ level1MethodCountData . push ( element [ 1 ] ) ;
187
+ }
166
188
167
189
// 레벨별 모듈 메소드(lv2)
190
+ // const level2MethodCountData = [];
191
+ // for (const key in data['py']['level_per_function_method']['level2']) {
192
+ // level2MethodCountData.push(
193
+ // data['py']['level_per_function_method']['level2'][key]
194
+ // );
195
+ // }
196
+ // const level2MethodCountLabels = Object.keys(
197
+ // data['py']['level_per_function_method']['level2']
198
+ // );
168
199
const level2MethodCountData = [ ] ;
169
- for ( const key in data [ 'py' ] [ 'level_per_function_method' ] [ 'level2' ] ) {
170
- level2MethodCountData . push (
171
- data [ 'py' ] [ 'level_per_function_method' ] [ 'level2' ] [ key ]
172
- ) ;
173
- }
174
- const level2MethodCountLabels = Object . keys (
200
+ const level2MethodCountLabels = [ ] ;
201
+
202
+ sorted = Object . entries (
175
203
data [ 'py' ] [ 'level_per_function_method' ] [ 'level2' ]
176
- ) ;
204
+ ) . sort ( ( a , b ) => b [ 1 ] - a [ 1 ] ) ;
205
+
206
+ for ( let element of sorted ) {
207
+ level2MethodCountLabels . push ( element [ 0 ] ) ;
208
+ level2MethodCountData . push ( element [ 1 ] ) ;
209
+ }
177
210
178
211
// 레벨별 모듈 메소드(lv3)
212
+ // const level3MethodCountData = [];
213
+ // for (const key in data['py']['level_per_function_method']['level3']) {
214
+ // level3MethodCountData.push(
215
+ // data['py']['level_per_function_method']['level3'][key]
216
+ // );
217
+ // }
218
+ // const level3MethodCountLabels = Object.keys(
219
+ // data['py']['level_per_function_method']['level3']
220
+ // );
179
221
const level3MethodCountData = [ ] ;
180
- for ( const key in data [ 'py' ] [ 'level_per_function_method' ] [ 'level3' ] ) {
181
- level3MethodCountData . push (
182
- data [ 'py' ] [ 'level_per_function_method' ] [ 'level3' ] [ key ]
183
- ) ;
184
- }
185
- const level3MethodCountLabels = Object . keys (
222
+ const level3MethodCountLabels = [ ] ;
223
+
224
+ sorted = Object . entries (
186
225
data [ 'py' ] [ 'level_per_function_method' ] [ 'level3' ]
187
- ) ;
226
+ ) . sort ( ( a , b ) => b [ 1 ] - a [ 1 ] ) ;
227
+
228
+ for ( let element of sorted ) {
229
+ level3MethodCountLabels . push ( element [ 0 ] ) ;
230
+ level3MethodCountData . push ( element [ 1 ] ) ;
231
+ }
188
232
189
233
// 레벨별 모듈 메소드(lv4)
190
234
if ( data [ 'py' ] [ 'level_per_function_method' ] [ 'level4' ] ) {
235
+ // const level4MethodCountData = [];
236
+ // for (const key in data['py']['level_per_function_method']['level4']) {
237
+ // level4MethodCountData.push(
238
+ // data['py']['level_per_function_method']['level4'][key]
239
+ // );
240
+ // }
241
+ // const level4MethodCountLabels = Object.keys(
242
+ // data['py']['level_per_function_method']['level4']
243
+ // );
191
244
const level4MethodCountData = [ ] ;
192
- for ( const key in data [ 'py' ] [ 'level_per_function_method' ] [ 'level4' ] ) {
193
- level4MethodCountData . push (
194
- data [ 'py' ] [ 'level_per_function_method' ] [ 'level4' ] [ key ]
195
- ) ;
196
- }
197
- const level4MethodCountLabels = Object . keys (
245
+ const level4MethodCountLabels = [ ] ;
246
+
247
+ sorted = Object . entries (
198
248
data [ 'py' ] [ 'level_per_function_method' ] [ 'level4' ]
199
- ) ;
249
+ ) . sort ( ( a , b ) => b [ 1 ] - a [ 1 ] ) ;
250
+
251
+ for ( let element of sorted ) {
252
+ level4MethodCountLabels . push ( element [ 0 ] ) ;
253
+ level4MethodCountData . push ( element [ 1 ] ) ;
254
+ }
200
255
201
256
const methodCountLv4Chart = new Chart (
202
257
document . getElementById ( 'level4-method-count-chart' ) ,
@@ -243,15 +298,26 @@ function getLevelDataPy(data, lang, charts) {
243
298
244
299
// 레벨별 모듈 메소드(lv5)
245
300
if ( data [ 'py' ] [ 'level_per_function_method' ] [ 'level5' ] ) {
301
+ // const level5MethodCountData = [];
302
+ // for (const key in data['py']['level_per_function_method']['level5']) {
303
+ // level5MethodCountData.push(
304
+ // data['py']['level_per_function_method']['level5'][key]
305
+ // );
306
+ // }
307
+ // const level5MethodCountLabels = Object.keys(
308
+ // data['py']['level_per_function_method']['level5']
309
+ // );
246
310
const level5MethodCountData = [ ] ;
247
- for ( const key in data [ 'py' ] [ 'level_per_function_method' ] [ 'level5' ] ) {
248
- level5MethodCountData . push (
249
- data [ 'py' ] [ 'level_per_function_method' ] [ 'level5' ] [ key ]
250
- ) ;
251
- }
252
- const level5MethodCountLabels = Object . keys (
311
+ const level5MethodCountLabels = [ ] ;
312
+
313
+ sorted = Object . entries (
253
314
data [ 'py' ] [ 'level_per_function_method' ] [ 'level5' ]
254
- ) ;
315
+ ) . sort ( ( a , b ) => b [ 1 ] - a [ 1 ] ) ;
316
+
317
+ for ( let element of sorted ) {
318
+ level5MethodCountLabels . push ( element [ 0 ] ) ;
319
+ level5MethodCountData . push ( element [ 1 ] ) ;
320
+ }
255
321
256
322
const methodCountLv5Chart = new Chart (
257
323
document . getElementById ( 'level5-method-count-chart' ) ,
0 commit comments