|
233 | 233 | * @private |
234 | 234 | */ |
235 | 235 | options: { |
236 | | - type: Array |
| 236 | + type: Array, |
| 237 | + value: function() { return []; } |
237 | 238 | }, |
238 | 239 |
|
239 | 240 | /** |
|
394 | 395 | var dataframe = event.target, |
395 | 396 | types = dataframe.value.columnTypes.map(function(datatype) { return this._columnType(datatype); }, this); |
396 | 397 |
|
397 | | - var independentIndex, dependentIndex; |
| 398 | + // in case value-changed hasn't fired yet, this.df will be needed by observers |
| 399 | + this.df = dataframe.value; |
398 | 400 |
|
399 | | - // regenerate both dropdown label based on latest listbox items |
| 401 | + // regenerate both dropdown label based on latest listbox items where current selection is no longer valid |
400 | 402 |
|
401 | | - this.options && this.options.some(function(option, i) { |
| 403 | + var independentOption, dependentOption; |
| 404 | + |
| 405 | + this.options.some(function(option, i) { |
402 | 406 | if (option.prop === 'x') { |
403 | | - independentIndex = 'options.' + i + '.index'; |
| 407 | + independentOption = i; |
404 | 408 | return true; |
405 | 409 | } |
406 | | - }) && this.set(independentIndex, null); |
| 410 | + }); |
407 | 411 |
|
408 | | - this.options && this.options.some(function(option, i) { |
| 412 | + this.options.some(function(option, i) { |
409 | 413 | if (option.prop === 'y') { |
410 | | - dependentIndex = 'options.' + i + '.index'; |
| 414 | + dependentOption = i; |
411 | 415 | return true; |
412 | 416 | } |
413 | | - }) && this.set(dependentIndex, null); |
| 417 | + }); |
414 | 418 |
|
415 | | - this.async(function() { |
| 419 | + if (independentOption !== undefined |
| 420 | + && dataframe.value.columns.indexOf(this.get('options.' + independentOption + '.column')) == -1) { |
416 | 421 | var independent = types.indexOf('temporal'); |
417 | 422 | if (independent == -1) independent = types.indexOf('quantitative'); |
418 | 423 | if (independent == -1) independent = 0; |
419 | 424 | types[independent] = null; |
420 | | - this.set('xOption.index', independent); |
421 | | - if (independentIndex !== undefined) this.set(independentIndex, independent); |
| 425 | + this.set('options.' + independentOption + '.index', null); |
| 426 | + this.async(function() { |
| 427 | + this.set('options.' + independentOption + '.index', independent); |
| 428 | + }); |
| 429 | + } |
422 | 430 |
|
| 431 | + if (dependentOption !== undefined |
| 432 | + && dataframe.value.columns.indexOf(this.get('options.' + dependentOption + '.column')) == -1) { |
423 | 433 | var dependent = types.indexOf('quantitative'); |
424 | 434 | if (dependent == -1) dependent = 0; |
425 | 435 | if (dependent == independent) dependent++; |
426 | 436 | types[dependent] = null; |
427 | | - this.set('yOption.index', dependent); |
428 | | - if (dependentIndex !== undefined) this.set(dependentIndex, dependent); |
429 | | - }); |
| 437 | + this.set('options.' + dependentOption + '.index', null); |
| 438 | + this.async(function() { |
| 439 | + this.set('options.' + dependentOption + '.index', dependent); |
| 440 | + }); |
| 441 | + } |
430 | 442 | }, |
431 | 443 |
|
432 | 444 | _rowsChanged: function(event) { |
|
0 commit comments