Draw labels
measure labels collisions
collapse close labels
493721
function () {
            if (!this.options) {
                return;
            }

            var values_num = this.options.values.length;
            var p_values = this.options.p_values;
            var text_single;
            var text_from;
            var text_to;
            var from_pretty;
            var to_pretty;

            if (this.options.hide_from_to) {
                return;
            }

            if (this.options.type === "single") {

                if (values_num) {
                    text_single = this.decorate(p_values[this.result.from]);
                    this.$cache.single.html(text_single);
                } else {
                    from_pretty = this._prettify(this.result.from);

                    text_single = this.decorate(from_pretty, this.result.from);
                    this.$cache.single.html(text_single);
                }

                this.calcLabels();

                if (this.labels.p_single_left < this.labels.p_min + 1) {
                    this.$cache.min[0].style.visibility = "hidden";
                } else {
                    this.$cache.min[0].style.visibility = "visible";
                }

                if (this.labels.p_single_left + this.labels.p_single_fake > 100 - this.labels.p_max - 1) {
                    this.$cache.max[0].style.visibility = "hidden";
                } else {
                    this.$cache.max[0].style.visibility = "visible";
                }

            } else {

                if (values_num) {

                    if (this.options.decorate_both) {
                        text_single = this.decorate(p_values[this.result.from]);
                        text_single += this.options.values_separator;
                        text_single += this.decorate(p_values[this.result.to]);
                    } else {
                        text_single = this.decorate(p_values[this.result.from] + this.options.values_separator + p_values[this.result.to]);
                    }
                    text_from = this.decorate(p_values[this.result.from]);
                    text_to = this.decorate(p_values[this.result.to]);

                    this.$cache.single.html(text_single);
                    this.$cache.from.html(text_from);
                    this.$cache.to.html(text_to);

                } else {
                    from_pretty = this._prettify(this.result.from);
                    to_pretty = this._prettify(this.result.to);

                    if (this.options.decorate_both) {
                        text_single = this.decorate(from_pretty, this.result.from);
                        text_single += this.options.values_separator;
                        text_single += this.decorate(to_pretty, this.result.to);
                    } else {
                        text_single = this.decorate(from_pretty + this.options.values_separator + to_pretty, this.result.to);
                    }
                    text_from = this.decorate(from_pretty, this.result.from);
                    text_to = this.decorate(to_pretty, this.result.to);

                    this.$cache.single.html(text_single);
                    this.$cache.from.html(text_from);
                    this.$cache.to.html(text_to);

                }

                this.calcLabels();

                var min = Math.min(this.labels.p_single_left, this.labels.p_from_left),
                    single_left = this.labels.p_single_left + this.labels.p_single_fake,
                    to_left = this.labels.p_to_left + this.labels.p_to_fake,
                    max = Math.max(single_left, to_left);

                if (this.labels.p_from_left + this.labels.p_from_fake >= this.labels.p_to_left) {
                    this.$cache.from[0].style.visibility = "hidden";
                    this.$cache.to[0].style.visibility = "hidden";
                    this.$cache.single[0].style.visibility = "visible";

                    if (this.result.from === this.result.to) {
                        if (this.target === "from") {
                            this.$cache.from[0].style.visibility = "visible";
                        } else if (this.target === "to") {
                            this.$cache.to[0].style.visibility = "visible";
                        } else if (!this.target) {
                            this.$cache.from[0].style.visibility = "visible";
                        }
                        this.$cache.single[0].style.visibility = "hidden";
                        max = to_left;
                    } else {
                        this.$cache.from[0].style.visibility = "hidden";
                        this.$cache.to[0].style.visibility = "hidden";
                        this.$cache.single[0].style.visibility = "visible";
                        max = Math.max(single_left, to_left);
                    }
                } else {
                    this.$cache.from[0].style.visibility = "visible";
                    this.$cache.to[0].style.visibility = "visible";
                    this.$cache.single[0].style.visibility = "hidden";
                }

                if (min < this.labels.p_min + 1) {
                    this.$cache.min[0].style.visibility = "hidden";
                } else {
                    this.$cache.min[0].style.visibility = "visible";
                }

                if (max > 100 - this.labels.p_max - 1) {
                    this.$cache.max[0].style.visibility = "hidden";
                } else {
                    this.$cache.max[0].style.visibility = "visible";
                }

            }
        }
323170
def check_label_shape(self, label_shape):
        """"""
        if not len(label_shape) == 2:
            raise ValueError('label_shape should have length 2')
        if label_shape[0] < self.label_shape[0]:
            msg = 'Attempts to reduce label count from %d to %d, not allowed.' \
                % (self.label_shape[0], label_shape[0])
            raise ValueError(msg)
        if label_shape[1] != self.provide_label[0][1][2]:
            msg = 'label_shape object width inconsistent: %d vs %d.' \
                % (self.provide_label[0][1][2], label_shape[1])
            raise ValueError(msg)
1363401
function drawSlices() {
            // Not ideal, we need to figure out how to call exit for nested elements
            if (slices) {
                svg.selectAll('g.arc').remove();
            }

            slices = svg.select('.chart-group')
                .selectAll('g.arc')
                .data(layout(data));

            let newSlices = slices.enter()
                .append('g')
                  .each(storeAngle)
                  .each(reduceOuterRadius)
                  .classed('arc', true)
                  .append('path');

            if (isAnimated) {
                newSlices.merge(slices)
                    .attr('fill', getSliceFill)
                    .on('mouseover', function(d) {
                        handleMouseOver(this, d, chartWidth, chartHeight);
                    })
                    .on('mousemove', function(d) {
                        handleMouseMove(this, d, chartWidth, chartHeight);
                    })
                    .on('mouseout', function(d) {
                        handleMouseOut(this, d, chartWidth, chartHeight);
                    })
                    .on('click', function(d) {
                        handleClick(this, d, chartWidth, chartHeight);
                    })
                    .transition()
                    .ease(ease)
                    .duration(pieDrawingTransitionDuration)
                    .attrTween('d', tweenLoading);
            } else {
                newSlices.merge(slices)
                    .attr('fill', getSliceFill)
                    .attr('d', shape)
                    .on('mouseover', function(d) {
                        handleMouseOver(this, d, chartWidth, chartHeight);
                    })
                    .on('mousemove', function(d) {
                        handleMouseMove(this, d, chartWidth, chartHeight);
                    })
                    .on('mouseout', function(d) {
                        handleMouseOut(this, d, chartWidth, chartHeight);
                    })
                    .on('click', function(d) {
                        handleClick(this, d, chartWidth, chartHeight);
                    });
            }

            slices.exit().remove();
        }
775192
function label(label) {
    return function(s) {
      var delta = s.length - label.length;
      return strRepeat (' ', Math.floor (delta / 2)) + label +
             strRepeat (' ', Math.ceil (delta / 2));
    };
  }
539809
def OnLabelSizeIntCtrl(self, event):
        """"""

        self.attrs["labelsize"] = event.GetValue()

        post_command_event(self, self.DrawChartMsg)
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
        }

      }

    }

  }
1076975
function showCrossHairComponentsWithLabels(status = false) {
            const opacityIndex = status ? 1 : 0;

            highlightCrossHairContainer.attr('opacity', opacityIndex);
            highlightCrossHairLabelsContainer.attr('opacity', opacityIndex);
        }
1248287
function(r, n) {
    var label = r.text(0, 30, n.label).attr({ opacity: 0 })
    //the Raphael set is obligatory, containing all you want to display
    var set = r.set()
      .push(
        r.rect(-30, -13, 62, 86)
          .attr({ fill: '#fa8', 'stroke-width': 2, r: 9 })
      )
      .push(label)

    // make the label show only on hover
    set.hover(
      function mouseIn() {
        label.animate({ opacity: 1, 'fill-opacity': 1 }, 500)
      },
      function mouseOut() {
        label.animate({ opacity: 0 }, 300)
      }
    )

    // TODO currently not implemented
    // var tooltip = r.set()
    //   .push(
    //     r.rect(0, 0, 90, 30).attr({ fill: '#fec', 'stroke-width': 1, r: 9 })
    //   ).push(
    //     r.text(25, 15, 'overlay').attr({ fill: '#000000' })
    //   );
    // for(var i in set.items) {
    //   set.items[i].tooltip(tooltip);
    // }
    //            set.tooltip(r.set().push(r.rect(0, 0, 30, 30).attr({"fill": "#fec", "stroke-width": 1, r : "9px"})).hide());
    return set
  }
17612
function () {
			var series = this,
				points = series.points,
				options,
				level,
				dataLabelsGroup = this.dataLabelsGroup,
				dataLabels;
			each(points, function (point) {
				if (point.node.isVisible) {
					level = series.levelMap[point.level];
					if (!point.isLeaf || level) {
						options = undefined;
						// If not a leaf, then label should be disabled as default
						if (!point.isLeaf) {
							options = {enabled: false};
						}
						if (level) {
							dataLabels = level.dataLabels;
							if (dataLabels) {
								options = merge(options, dataLabels);
								series._hasPointLabels = true;
							}
						}
						options = merge(options, point.options.dataLabels);
						point.dlOptions = options;
					} else {
						delete point.dlOptions;
					}
				}
			});
			this.dataLabelsGroup = this.group;
			Series.prototype.drawDataLabels.call(this);
			this.dataLabelsGroup = dataLabelsGroup;
		}
1284913
function(width, height) {
      this.getPos(true);
      this.translateOffsetX = this.translateOffsetY = 0;
      this.scaleOffsetX = this.scaleOffsetY = 1;
      for(var i=0, l=this.canvases.length; i<l; i++) {
        this.canvases[i].resize(width, height);
      }
      var style = this.element.style;
      style.width = width + 'px';
      style.height = height + 'px';
      if(this.labelContainer)
        this.labelContainer.style.width = width + 'px';
    }
196315
def annotate(draw, width, height, x, y, text, &block)
      check_destroyed
      draw.annotate(self, width, height, x, y, text, &block)
      self
    end
239513
def distance_to_edge(labels):
    '''
    '''
    colors = color_labels(labels)
    max_color = np.max(colors)
    result = np.zeros(labels.shape)
    if max_color == 0:
        return result
    
    for i in range(1, max_color+1):
        mask = (colors==i)
        result[mask] = scind.distance_transform_edt(mask)[mask]
    return result
484827
private void paintClosePressed(Graphics2D g, JComponent c, int width, int height) {
        paintClose(g, c, width, height, pressed);
    }
701430
def draw_label(self, layout_info, ax):
        
        label_info = layout_info[list(self.vars)]
        label_info._meta = {'dimension': 'cols'}
        label_info = self.labeller(label_info)
        self.draw_strip_text(label_info, 'top', ax)
809694
def chart_measure(self, bars):
        
        width = 0
        for bar in bars:
            # Calculate maximum from:
            width = max(
                width,                      # current label max width
                len(bar.get('label', '')),  # column label width
                bar.get('width_min', 0),    # configured column minimal width
            )
        return width
1250229
def draw_annotation(img, boxes, klass, is_crowd=None):
    """"""
    labels = []
    assert len(boxes) == len(klass)
    if is_crowd is not None:
        assert len(boxes) == len(is_crowd)
        for cls, crd in zip(klass, is_crowd):
            clsname = cfg.DATA.CLASS_NAMES[cls]
            if crd == 1:
                clsname += ';Crowd'
            labels.append(clsname)
    else:
        for cls in klass:
            labels.append(cfg.DATA.CLASS_NAMES[cls])
    img = viz.draw_boxes(img, boxes, labels)
    return img
49231
private void drawXLabel(Graphics2D chartGraphics) {
    if (xAxisLabel != null) {
      // Strings are drawn from the baseline position of the leftmost char.
      int yPosXAxisLabel = chartSize.height - (margin / 2) - xAxisLabelDescent;
      // TODO This will need to be updated if the y-axis values/label can be moved to the right.
      int xPosXAxisLabel = heatMapC.x - (xAxisLabelSize.width / 2);

      chartGraphics.setFont(axisLabelsFont);
      chartGraphics.setColor(axisLabelColour);
      chartGraphics.drawString(xAxisLabel, xPosXAxisLabel, yPosXAxisLabel);
    }
  }