()
| 53 | } |
| 54 | |
| 55 | _preprocessData () { |
| 56 | const keep = []; |
| 57 | let childrenChanged; |
| 58 | |
| 59 | const nesting = d3compat.nester({ |
| 60 | key: this._seriesAccessor, |
| 61 | sortKeys: this._seriesSort, |
| 62 | sortValues: this._valueSort, |
| 63 | entries: this.data() |
| 64 | }); |
| 65 | |
| 66 | const children = |
| 67 | nesting.map((sub, i) => { |
| 68 | const subChart = this._charts[sub.key] || this._chartFunction(this, this._chartGroup , sub.key, i); |
| 69 | if (!this._charts[sub.key]) { |
| 70 | childrenChanged = true; |
| 71 | } |
| 72 | this._charts[sub.key] = subChart; |
| 73 | keep.push(sub.key); |
| 74 | return subChart |
| 75 | .dimension(this.dimension()) |
| 76 | .group({ |
| 77 | all: typeof sub.values === 'function' ? sub.values : utils.constant(sub.values) |
| 78 | }, sub.key) |
| 79 | .keyAccessor(this.keyAccessor()) |
| 80 | .valueAccessor(this.valueAccessor()) |
| 81 | .brushOn(false); |
| 82 | }); |
| 83 | // this works around the fact compositeChart doesn't really |
| 84 | // have a removal interface |
| 85 | Object.keys(this._charts) |
| 86 | .filter(c => keep.indexOf(c) === -1) |
| 87 | .forEach(c => { |
| 88 | this._clearChart(c); |
| 89 | childrenChanged = true; |
| 90 | }); |
| 91 | this._compose(children); |
| 92 | if (childrenChanged && this.legend()) { |
| 93 | this.legend().render(); |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | _clearChart (c) { |
| 98 | if (this._charts[c].g()) { |
nothing calls this directly
no test coverage detected