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

Method drawBars

js/src/Bars.ts:358–474  ·  view source on GitHub ↗
(animate?: boolean)

Source from the content-addressed store, hash-verified

356 }
357
358 private drawBars(animate?: boolean) {
359 const barGroups = this.d3el.selectAll('.bargroup');
360 const barsSel = barGroups.selectAll('.bar');
361 const animationDuration =
362 animate === true ? this.parent.model.get('animation_duration') : 0;
363
364 const domScale = this.domScale;
365 const rangeScale = this.rangeScale.scale;
366
367 const dom = this.orientation === 'vertical' ? 'x' : 'y';
368 const rang = this.orientation === 'vertical' ? 'y' : 'x';
369
370 const domControl = this.orientation === 'vertical' ? 'width' : 'height';
371 const rangeControl = this.orientation === 'vertical' ? 'height' : 'width';
372
373 if (isOrdinalScale(domScale)) {
374 const domMax = d3.max(this.parent.range(dom));
375 barGroups.attr('transform', (d: BarData) => {
376 if (this.orientation === 'vertical') {
377 return (
378 'translate(' +
379 ((domScale.scale(d.key) !== undefined
380 ? domScale.scale(d.key)
381 : domMax) +
382 this.domOffset) +
383 ', 0)'
384 );
385 } else {
386 return (
387 'translate(0, ' +
388 ((domScale.scale(d.key) !== undefined
389 ? domScale.scale(d.key)
390 : domMax) +
391 this.domOffset) +
392 ')'
393 );
394 }
395 });
396 } else {
397 barGroups.attr('transform', (d: BarData) => {
398 if (this.orientation === 'vertical') {
399 return (
400 'translate(' + (domScale.scale(d.key) + this.domOffset) + ', 0)'
401 );
402 } else {
403 return (
404 'translate(0, ' + (domScale.scale(d.key) + this.domOffset) + ')'
405 );
406 }
407 });
408 }
409
410 const isStacked = this.model.get('type') === 'stacked';
411 let bandWidth = 1.0;
412 if (isStacked) {
413 bandWidth = Math.max(1.0, this.stackedScale.bandwidth());
414 barsSel
415 .transition()

Callers 2

relayoutMethod · 0.95
drawMethod · 0.95

Calls 2

manageBarLabelsMethod · 0.95
rangeMethod · 0.80

Tested by

no test coverage detected