()
| 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 |
no test coverage detected