Crude approximation of what the label width might be
@private
964217
function(label) {
		var me = this;
		var ticksOpts = me.options.ticks;
		var tickLabelWidth = me.ctx.measureText(label).width;
		var angle = helpers.toRadians(ticksOpts.maxRotation);
		var cosRotation = Math.cos(angle);
		var sinRotation = Math.sin(angle);
		var tickFontSize = valueOrDefault(ticksOpts.fontSize, defaults.global.defaultFontSize);

		return (tickLabelWidth * cosRotation) + (tickFontSize * sinRotation);
	}
825895
function(tpl, data, label) {
    var t = String(tpl),
      s = label || /#\{([^}]*)\}/mg,
      trim = String.trim ||
      function(str) {
          return str.replace(/^\s+|\s+$/g, "")
      }
    return t.replace(s, function(value, name) {
      value = data[trim(name)]
      // only handle `undefined`
      return value === undefined ? "" : value
    })
  }
528881
function(segment_sizes, total_size, line, layout){
        // The passes done for fitting a label, and provided tolerances for each pass
        // First straight is chosen with a low tolerance. Then curved. Then straight with a higher tolerance.
        const passes = [
            { type: 'straight', tolerance : (layout.no_curving) ? LINE_EXCEED_STRAIGHT_NO_CURVE : LINE_EXCEED_STRAIGHT },
            { type: 'curved' },
            { type: 'straight', tolerance : LINE_EXCEED_STAIGHT_LOOSE }
        ];

        // loop through passes. first label found wins.
        for (let i = 0; i < passes.length; i++){
            let check = passes[i];
            let label;
            if (check.type === 'straight'){
                label = new LabelLineStraight(total_size, line, layout, check.tolerance);
            }
            else if (check.type === 'curved' && !layout.no_curving && line.length > 2){
                label = new LabelLineCurved(segment_sizes, line, layout);
            }

            if (label && !label.throw_away) {
                return label;
            }
        }

        return false;
    }
332055
function () {
        var dimension = cliUtils.dimension(),
            // note that similar dimension calculation is in utils.wrapper
            width = ((dimension.exists && (dimension.width > 20)) ? dimension.width : 60) - 6;

        return function (text, indent) {
            return wrap(text, {
                indent: indent,
                width: width,
                cut: true
            });
        };
    }
593068
def space_labels(document):
    """"""
    for label in document.xpath('.//bold'):
        # TODO: Make this more permissive to match chemical_label in parser
        if not label.text or not re.match('^\(L?\d\d?[a-z]?\):?$', label.text, re.I):
            continue
        parent = label.getparent()
        previous = label.getprevious()
        if previous is None:
            text = parent.text or ''
            if not text.endswith(' '):
                parent.text = text + ' '
        else:
            text = previous.tail or ''
            if not text.endswith(' '):
                previous.tail = text + ' '
        text = label.tail or ''
        if not text.endswith(' '):
            label.tail = text + ' '
    return document
1009348
def label_position(self):
        '''
        
        '''
        reg_sizes = [(r.size(), r) for r in self.pieces]
        reg_sizes.sort()
        return reg_sizes[-1][1].label_position()
568327
function label(d) {

    delete d.d3plus_label

    if (vars.g.edges.selectAll("line, path").size() < vars.edges.large && vars.edges.label && d[vars.edges.label]) {

      if ("spline" in d.d3plus) {

        var length = this.getTotalLength(),
            center = this.getPointAtLength(length/2),
            prev = this.getPointAtLength((length/2)-(length*.1)),
            next = this.getPointAtLength((length/2)+(length*.1)),
            radians = Math.atan2(next.y-prev.y,next.x-prev.x),
            angle = radians*(180/Math.PI),
            bounding = this.parentNode.getBBox(),
            width = length*.8,
            x = center.x,
            y = center.y

      }
      else {

        var bounds = this.getBBox(),
            source = d[vars.edges.source],
            target = d[vars.edges.target],
            start = {"x": source.d3plus.edges[target[vars.id.value]].x, "y": source.d3plus.edges[target[vars.id.value]].y},
            end = {"x": target.d3plus.edges[source[vars.id.value]].x, "y": target.d3plus.edges[source[vars.id.value]].y},
            xdiff = end.x-start.x,
            ydiff = end.y-start.y,
            center = {"x": end.x-(xdiff)/2, "y": end.y-(ydiff)/2},
            radians = Math.atan2(ydiff,xdiff),
            angle = radians*(180/Math.PI),
            length = Math.sqrt((xdiff*xdiff)+(ydiff*ydiff)),
            width = length,
            x = center.x,
            y = center.y

      }

      width += vars.labels.padding*2

      var m = 0
      if (vars.edges.arrows.value) {
        m = typeof vars.edges.arrows.value === "number"
          ? vars.edges.arrows.value : 8
        m = m/vars.zoom.behavior.scaleExtent()[1]
        width -= m*2
      }

      if (angle < -90 || angle > 90) {
        angle -= 180
      }

      if (width*vars.zoom.behavior.scaleExtent()[0] > 20) {

        d.d3plus_label = {
          "x": x,
          "y": y,
          "translate": {"x": x, "y": y},
          "w": width,
          "h": 15+vars.labels.padding*2,
          "angle": angle,
          "anchor": "middle",
          "valign": "center",
          "color": vars.edges.color,
          "resize": false,
          "names": [vars.format.value(d[vars.edges.label])],
          "background": 1
        }

      }

    }

  }
861324
function getPadding(str, width) {
  const spaceLen = (typeof width === 'undefined' ? 30 : width) - str.length;
  let padding = '';

  padding += '  ';
  for (let i = 2; i < spaceLen; i += 1) {
    padding += '-';
  }
  padding += '  ';
  return padding;
}
996955
def viewable_width(self):
        
        return sum(self.widths) + sum(x['padding'] for x in self.colspec)
131891
function getLineWidth(itemModel, rawLayout) {
    var lineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0;
    return Math.min(lineWidth, Math.abs(rawLayout.width), Math.abs(rawLayout.height));
}
1328647
def label(self, value):
        
        # Fixed width label formatting
        value = value[:self.pad_size] if self.pad_size else value
        try:
            padding = ' ' * (self.pad_size - len(value)) if self.pad_size else ''
        except TypeError:
            padding = ''

        self._formatted = ' {v}{p} '.format(v=value, p=padding)
485805
def _visible_width(s):
    
    if isinstance(s, _text_type) or isinstance(s, _binary_type):
        return len(_strip_invisible(s))
    else:
        return len(_text_type(s))
986240
function fitBox(box) {
			var minBoxSize = helpers$1.findNextWhere(minBoxSizes, function(minBox) {
				return minBox.box === box;
			});

			if (minBoxSize) {
				if (minBoxSize.horizontal) {
					var scaleMargin = {
						left: Math.max(outerBoxSizes.left, maxPadding.left),
						right: Math.max(outerBoxSizes.right, maxPadding.right),
						top: 0,
						bottom: 0
					};

					// Don't use min size here because of label rotation. When the labels are rotated, their rotation highly depends
					// on the margin. Sometimes they need to increase in size slightly
					box.update(box.fullWidth ? chartWidth : maxChartAreaWidth, chartHeight / 2, scaleMargin);
				} else {
					box.update(minBoxSize.width, maxChartAreaHeight);
				}
			}
		}
772595
function calcPreferredSize(pw) {
            if (arguments.length > 0) {
                var bl = [];
                if (this.$lastWidth < 0 || this.$lastWidth !== pw) {
                    bl = this.$breakToLines(pw);
                } else {
                    bl = this.$brokenLines;
                }

                return {
                    width  : pw,
                    height : bl.length * this.getLineHeight() +
                            (bl.length - 1) * this.lineIndent
                };
            } else {
                return this.$super();
            }
        }
886108
def _fixSize(self):
        """"""
        self.height = 0
        for o in self.options:
            text = o['label']
            font = o['font']
            ren = font.render(text, 1, (0, 0, 0))
            if ren.get_width() > self.width:
                self.width = ren.get_width()
            self.height += font.get_height()
211789
def _estimate_label_shape(self):
        """"""
        max_count = 0
        self.reset()
        try:
            while True:
                label, _ = self.next_sample()
                label = self._parse_label(label)
                max_count = max(max_count, label.shape[0])
        except StopIteration:
            pass
        self.reset()
        return (max_count, label.shape[1])
1088918
function(node, text, settings) {
      var prefix = settings('prefix') || '',
          size = node[prefix + 'size'];

      var fontSize = (settings('labelSize') === 'fixed') ?
        settings('defaultLabelSize') :
        settings('labelSizeRatio') * size;

      // Case when we don't want to display the label
      if (!settings('forceLabels') && size < settings('labelThreshold'))
        return;

      if (typeof node.label !== 'string')
        return;

      // Updating
      text.setAttributeNS(null, 'x',
        Math.round(node[prefix + 'x'] + size + 3));
      text.setAttributeNS(null, 'y',
        Math.round(node[prefix + 'y'] + fontSize / 3));

      // Showing
      text.style.display = '';

      return this;
    }