| 152 | } |
| 153 | |
| 154 | private updateLinkData() { |
| 155 | const link_color_scale = this.getScales().link_color; |
| 156 | this.link_data = this.get('link_data') || []; |
| 157 | let link_matrix = this.get('link_matrix'); |
| 158 | const link_color = this.get('link_color'); |
| 159 | |
| 160 | if (link_color_scale !== undefined && link_color.length > 0) { |
| 161 | link_matrix = link_color; |
| 162 | } |
| 163 | |
| 164 | // Coerce link matrix into format understandable by d3 force layout |
| 165 | if (this.link_data.length === 0 && link_matrix.length > 0) { |
| 166 | link_matrix.forEach((d: number[], i: number) => { |
| 167 | d.forEach((e, j) => { |
| 168 | if (e !== null && i != j) { |
| 169 | this.link_data.push({ |
| 170 | source: this.mark_data[i], |
| 171 | target: this.mark_data[j], |
| 172 | value: e, |
| 173 | }); |
| 174 | } |
| 175 | }); |
| 176 | }); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | update_data() { |
| 181 | this.dirty = true; |