(seriesModel: ChordSeriesModel, ecModel: GlobalModel, api: ExtensionAPI)
| 42 | } |
| 43 | |
| 44 | render(seriesModel: ChordSeriesModel, ecModel: GlobalModel, api: ExtensionAPI) { |
| 45 | const data = seriesModel.getData(); |
| 46 | const oldData = this._data; |
| 47 | const group = this.group; |
| 48 | |
| 49 | const startAngle = -seriesModel.get('startAngle') * RADIAN; |
| 50 | |
| 51 | data.diff(oldData) |
| 52 | .add((newIdx) => { |
| 53 | /* Consider the case when there are only two nodes A and B, |
| 54 | * and there is a link between A and B. |
| 55 | * At first, they are both disselected from legend. And then |
| 56 | * when A is selected, A will go into `add` method. But since |
| 57 | * there are no edges to be displayed, A should not be added. |
| 58 | * So we should only add A when layout is defined. |
| 59 | */ |
| 60 | |
| 61 | const layout = data.getItemLayout(newIdx); |
| 62 | if (layout) { |
| 63 | const el = new ChordPiece(data, newIdx, startAngle); |
| 64 | getECData(el).dataIndex = newIdx; |
| 65 | group.add(el); |
| 66 | } |
| 67 | }) |
| 68 | |
| 69 | .update((newIdx, oldIdx) => { |
| 70 | let el = oldData.getItemGraphicEl(oldIdx) as ChordPiece; |
| 71 | const layout = data.getItemLayout(newIdx); |
| 72 | |
| 73 | /* Consider the case when there are only two nodes A and B, |
| 74 | * and there is a link between A and B. |
| 75 | * and when A is disselected from legend, there should be |
| 76 | * nothing to display. But in the `data.diff` method, B will go |
| 77 | * into `update` method and having no layout. |
| 78 | * In this case, we need to remove B. |
| 79 | */ |
| 80 | if (!layout) { |
| 81 | el && graphic.removeElementWithFadeOut(el, seriesModel, oldIdx); |
| 82 | return; |
| 83 | } |
| 84 | |
| 85 | if (!el) { |
| 86 | el = new ChordPiece(data, newIdx, startAngle); |
| 87 | } |
| 88 | else { |
| 89 | el.updateData(data, newIdx, startAngle); |
| 90 | } |
| 91 | group.add(el); |
| 92 | }) |
| 93 | |
| 94 | .remove(oldIdx => { |
| 95 | const el = oldData.getItemGraphicEl(oldIdx) as ChordPiece; |
| 96 | el && graphic.removeElementWithFadeOut(el, seriesModel, oldIdx); |
| 97 | }) |
| 98 | |
| 99 | .execute(); |
| 100 | |
| 101 | if (!oldData) { |
nothing calls this directly
no test coverage detected