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

Method transformBarLabel

js/src/Bars.ts:620–649  ·  view source on GitHub ↗

* Applies CSS translate to shift label position according * to vertical/horizontal offsets * @param d - Data point * @param offsetHorizontal - Horizontal offset, in pixels, of the label * @param offsetVertical - Vertical offset, in pixels, of the label * @param bandWidth - Bandwidth p

(
    d: BarGroupValue,
    offsetHorizontal: number,
    offsetVertical: number,
    bandWidth: number
  )

Source from the content-addressed store, hash-verified

618 * @param bandWidth - Bandwidth parameter for the bar dimantions
619 */
620 private transformBarLabel(
621 d: BarGroupValue,
622 offsetHorizontal: number,
623 offsetVertical: number,
624 bandWidth: number
625 ): string {
626 if (this.orientation === 'horizontal') {
627 return d.y <= this.baseLine
628 ? `translate(${
629 d.y0 <= this.baseLine ? 0 - offsetVertical : 0 + offsetVertical
630 }, ${bandWidth / 2 + offsetHorizontal})`
631 : `translate(${
632 d.y1 <= this.baseLine ? 0 - offsetVertical : 0 + offsetVertical
633 }, ${bandWidth / 2 + offsetHorizontal})`;
634 } else {
635 return d.y <= this.baseLine
636 ? `translate(${bandWidth / 2 + offsetHorizontal},
637 ${
638 d.y0 <= this.baseLine
639 ? 0 - offsetVertical
640 : 0 + offsetVertical
641 })`
642 : `translate(${bandWidth / 2 + offsetHorizontal},
643 ${
644 d.y1 <= this.baseLine
645 ? 0 - offsetVertical
646 : 0 + offsetVertical
647 })`;
648 }
649 }
650
651 /**
652 * Determines the value of the text-anchor CSS attribute

Callers 2

stackedBarLabelsMethod · 0.95
groupedBarLabelsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected