MCPcopy
hub / github.com/dc-js/dc.js / _doRedraw

Method _doRedraw

src/charts/heatmap.js:201–323  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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');

Callers 1

_doRenderMethod · 0.95

Calls 15

rowsMethod · 0.95
colsMethod · 0.95
boxOnClickMethod · 0.95
xAxisOnClickMethod · 0.95
colsLabelMethod · 0.95
yAxisOnClickMethod · 0.95
rowsLabelMethod · 0.95
transitionFunction · 0.90
dataMethod · 0.80
valueAccessorMethod · 0.80
keyAccessorMethod · 0.80
effectiveWidthMethod · 0.80

Tested by

no test coverage detected