()
| 199 | } |
| 200 | |
| 201 | _doRedraw () { |
| 202 | const data = this.data(); |
| 203 | let rows = this.rows() || data.map(this.valueAccessor()), |
| 204 | cols = this.cols() || data.map(this.keyAccessor()); |
| 205 | if (this._rowOrdering) { |
| 206 | rows = rows.sort(this._rowOrdering); |
| 207 | } |
| 208 | if (this._colOrdering) { |
| 209 | cols = cols.sort(this._colOrdering); |
| 210 | } |
| 211 | rows = this._rowScale.domain(rows); |
| 212 | cols = this._colScale.domain(cols); |
| 213 | |
| 214 | const rowCount = rows.domain().length, |
| 215 | colCount = cols.domain().length, |
| 216 | boxWidth = Math.floor(this.effectiveWidth() / colCount), |
| 217 | boxHeight = Math.floor(this.effectiveHeight() / rowCount); |
| 218 | |
| 219 | cols.rangeRound([0, this.effectiveWidth()]); |
| 220 | rows.rangeRound([this.effectiveHeight(), 0]); |
| 221 | |
| 222 | let boxes = this._chartBody.selectAll('g.box-group').data(this.data(), |
| 223 | (d, i) => `${this.keyAccessor()(d, i)}\0${this.valueAccessor()(d, i)}`); |
| 224 | |
| 225 | boxes.exit().remove(); |
| 226 | |
| 227 | const gEnter = boxes.enter().append('g') |
| 228 | .attr('class', 'box-group'); |
| 229 | |
| 230 | gEnter.append('rect') |
| 231 | .attr('class', 'heat-box') |
| 232 | .classed('dc-tabbable', this._keyboardAccessible) |
| 233 | .attr('fill', 'white') |
| 234 | .attr('x', (d, i) => cols(this.keyAccessor()(d, i))) |
| 235 | .attr('y', (d, i) => rows(this.valueAccessor()(d, i))) |
| 236 | .on('click', d3compat.eventHandler(this.boxOnClick())); |
| 237 | |
| 238 | if (this._keyboardAccessible) { |
| 239 | this._makeKeyboardAccessible(this.boxOnClick); |
| 240 | } |
| 241 | |
| 242 | boxes = gEnter.merge(boxes); |
| 243 | |
| 244 | if (this.renderTitle()) { |
| 245 | gEnter.append('title'); |
| 246 | boxes.select('title').text(this.title()); |
| 247 | } |
| 248 | |
| 249 | transition(boxes.select('rect'), this.transitionDuration(), this.transitionDelay()) |
| 250 | .attr('x', (d, i) => cols(this.keyAccessor()(d, i))) |
| 251 | .attr('y', (d, i) => rows(this.valueAccessor()(d, i))) |
| 252 | .attr('rx', this._xBorderRadius) |
| 253 | .attr('ry', this._yBorderRadius) |
| 254 | .attr('fill', this.getColor) |
| 255 | .attr('width', boxWidth) |
| 256 | .attr('height', boxHeight); |
| 257 | |
| 258 | let gCols = this._chartBody.select('g.cols'); |
no test coverage detected