MCPcopy
hub / github.com/tensorflow/playground / updateCircles

Method updateCircles

src/heatmap.ts:182–207  ·  view source on GitHub ↗
(container, points: Example2D[])

Source from the content-addressed store, hash-verified

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
210export function reduceMatrix(matrix: number[][], factor: number): number[][] {

Callers 2

updateTestPointsMethod · 0.95
updatePointsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected