(container, points: Example2D[])
| 180 | } |
| 181 | |
| 182 | private updateCircles(container, points: Example2D[]) { |
| 183 | // Keep only points that are inside the bounds. |
| 184 | let xDomain = this.xScale.domain(); |
| 185 | let yDomain = this.yScale.domain(); |
| 186 | points = points.filter(p => { |
| 187 | return p.x >= xDomain[0] && p.x <= xDomain[1] |
| 188 | && p.y >= yDomain[0] && p.y <= yDomain[1]; |
| 189 | }); |
| 190 | |
| 191 | // Attach data to initially empty selection. |
| 192 | let selection = container.selectAll("circle").data(points); |
| 193 | |
| 194 | // Insert elements to match length of points array. |
| 195 | selection.enter().append("circle").attr("r", 3); |
| 196 | |
| 197 | // Update points to be in the correct position. |
| 198 | selection |
| 199 | .attr({ |
| 200 | cx: (d: Example2D) => this.xScale(d.x), |
| 201 | cy: (d: Example2D) => this.yScale(d.y), |
| 202 | }) |
| 203 | .style("fill", d => this.color(d.label)); |
| 204 | |
| 205 | // Remove points if the length has gone down. |
| 206 | selection.exit().remove(); |
| 207 | } |
| 208 | } // Close class HeatMap. |
| 209 | |
| 210 | export function reduceMatrix(matrix: number[][], factor: number): number[][] { |
no outgoing calls
no test coverage detected