Suppressed data label

author(s): Kzoon

by kzoon

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>

<div id="container" style="height: 400px; width:280px"></div>

JavaScript

(function(H) {
  var addEvent = H.addEvent,
    arrayMax = H.arrayMax,
    defined = H.defined,
    extend = H.extend,
    format = H.format,
    merge = H.merge,
    noop = H.noop,
    pick = H.pick,
    relativeLength = H.relativeLength,
    Series = H.Series,
    seriesTypes = H.seriesTypes,
    stableSort = H.stableSort,
    isArray = H.isArray,
    splat = H.splat;

  H.Series.prototype.alignDataLabel = function(
    point,
    dataLabel,
    options,
    alignTo,
    isNew
  ) {
    var chart = this.chart,
      inverted = this.isCartesian && chart.inverted,
      plotX = pick(point.dlBox && point.dlBox.centerX, point.plotX, -9999),
      plotY = pick(point.plotY, -9999),
      bBox = dataLabel.getBBox(),
      baseline,
      rotation = options.rotation,
      normRotation,
      negRotation,
      align = options.align,
      rotCorr, // rotation correction
      // Math.round for rounding errors (#2683), alignTo to allow column
      // labels (#2700)
      visible =
      this.visible &&
      (
        point.series.forceDL ||
        chart.isInsidePlot(plotX, Math.round(plotY), inverted) ||
        (
          alignTo && chart.isInsidePlot(
            plotX,
            inverted ?
            alignTo.x + 1 :
            alignTo.y + alignTo.height - 1,
            inverted
          )
        )
      ),
      alignAttr, // the final position;
      justify = pick(options.overflow, 'justify') === 'justify';

    if (visible) {

      baseline = chart.renderer.fontMetrics(
        chart.styledMode ? undefined : options.style.fontSize,
        dataLabel
      ).b;

      // The alignment box is a singular point
      alignTo = extend({
        x: inverted ? this.yAxis.len - plotY : plotX,
        y: Math.round(inverted ? this.xAxis.len - plotX : plotY),
        width: 0,
        height: 0
      }, alignTo);

      // Add the text size for alignment calculation
      extend(options, {
        width: bBox.width,
        height: bBox.height
      });

     ...