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

Method stackedBarLabels

js/src/Bars.ts:546–574  ·  view source on GitHub ↗

* All bars are stacked by default. The only other value this parameter can take is 'grouped' * @param barGroups - D3 selection for bar groups * @param bandWidth - Bandwidth parameter for the bar dimensions * @param dom - X or y axis (depending on oridnetation) * @param rang - X or y axis

(
    barGroups: any,
    bandWidth: number,
    dom: string,
    rang: string
  )

Source from the content-addressed store, hash-verified

544 * @param rang - X or y axis (depending on oridnetation)
545 */
546 private stackedBarLabels(
547 barGroups: any,
548 bandWidth: number,
549 dom: string,
550 rang: string
551 ): void {
552 const barLabels = barGroups.selectAll('.bar_label');
553
554 barLabels
555 .attr(dom, (d) => 0)
556 .attr(rang, (d) => {
557 if (d.y <= this.baseLine) {
558 return this.rangeScale.scale(d.y0);
559 } else {
560 return this.rangeScale.scale(d.y1);
561 }
562 })
563 .style('font-weight', '400')
564 .style('text-anchor', (d) => this.styleBarLabelTextAnchor(d))
565 .style('dominant-baseline', (d) => this.styleBarLabelDominantBaseline(d))
566 .attr('transform', (d, i) => {
567 return this.transformBarLabel(
568 d,
569 this.offsetHorizontal,
570 this.offsetVertical,
571 bandWidth
572 );
573 });
574 }
575
576 /**
577 * Add labels for a chart with grouped bars

Callers 1

manageBarLabelsMethod · 0.95

Calls 3

transformBarLabelMethod · 0.95

Tested by

no test coverage detected