MCPcopy Index your code
hub / github.com/bqplot/bqplot / draw

Method draw

js/src/HeatMap.ts:114–143  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

112 }
113
114 draw() {
115 this.set_ranges();
116
117 const plottingData = this.getPlottingData();
118
119 this.canvas.setAttribute('width', plottingData.totalWidth.toString());
120 this.canvas.setAttribute('height', plottingData.totalHeight.toString());
121
122 const ctx = this.canvas.getContext('2d');
123 const colors = this.model.mark_data.color;
124 colors.forEach((row: number[], i: number) => {
125 const height = plottingData.heights[i];
126 const y = plottingData.yOrigin + plottingData.yStartPoints[i];
127
128 row.forEach((d: number, j: number) => {
129 const width = plottingData.widths[j];
130 const x = plottingData.xOrigin + plottingData.xStartPoints[j];
131 ctx.fillStyle = this.getElementFill(d);
132 ctx.fillRect(x, y, this.expandRect(width), this.expandRect(height));
133 });
134 });
135
136 this.image
137 .attr('width', plottingData.totalWidth)
138 .attr('height', plottingData.totalHeight)
139 .attr('x', plottingData.x0)
140 .attr('y', plottingData.y0);
141
142 this.drawCanvas();
143 }
144
145 private expandRect(value: number): number {
146 // Add 0.5px to width and height to fill gaps between rectangles

Callers 4

renderMethod · 0.95
set_positional_scalesMethod · 0.95
relayoutMethod · 0.95

Calls 5

set_rangesMethod · 0.95
getPlottingDataMethod · 0.95
getElementFillMethod · 0.95
expandRectMethod · 0.95
drawCanvasMethod · 0.95

Tested by

no test coverage detected