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

Method groupedBarLabels

js/src/Bars.ts:581–610  ·  view source on GitHub ↗

* Add labels for a chart with grouped bars * @param barGroups - D3 selection for bar group * @param bandWidth - bandwidth parameter for the X axis

(barGroups: any, bandWidth: number)

Source from the content-addressed store, hash-verified

579 * @param bandWidth - bandwidth parameter for the X axis
580 */
581 private groupedBarLabels(barGroups: any, bandWidth: number): void {
582 const barLabels = barGroups.selectAll('.bar_label');
583
584 barLabels
585 .attr('x', (d, i) => {
586 if (this.orientation === 'horizontal') {
587 return this.rangeScale.scale(d.y);
588 } else {
589 return this.groupedScale(i);
590 }
591 })
592 .attr('y', (d, i) => {
593 if (this.orientation === 'horizontal') {
594 return this.groupedScale(i);
595 } else {
596 return this.rangeScale.scale(d.y);
597 }
598 })
599 .style('font-weight', '400')
600 .style('text-anchor', (d) => this.styleBarLabelTextAnchor(d))
601 .style('dominant-baseline', (d) => this.styleBarLabelDominantBaseline(d))
602 .attr('transform', (d) =>
603 this.transformBarLabel(
604 d,
605 this.offsetHorizontal,
606 this.offsetVertical,
607 bandWidth
608 )
609 );
610 }
611
612 /**
613 * Applies CSS translate to shift label position according

Callers 1

manageBarLabelsMethod · 0.95

Calls 3

transformBarLabelMethod · 0.95

Tested by

no test coverage detected