New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legend with proximate option #8638

Closed
VBIManonmaniM opened this Issue Jul 18, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@VBIManonmaniM

VBIManonmaniM commented Jul 18, 2018

Expected behaviour
Legend with proximate option have to work with all kind of Series Data.

Actual behaviour
But it is not working properly with Series with all null data

Live demo with steps to reproduce
https://jsfiddle.net/v24xsjh8/4/

Product version
Highcharts

Affected browser(s)
All browsers

@pawelfus

This comment has been minimized.

Show comment
Hide comment
@pawelfus

pawelfus Jul 18, 2018

Contributor

Thanks for reporting @VBIManonmaniM !

Contributor

pawelfus commented Jul 18, 2018

Thanks for reporting @VBIManonmaniM !

@pawelfus pawelfus added the Bug label Jul 18, 2018

@pawelfus

This comment has been minimized.

Show comment
Hide comment
@pawelfus

pawelfus Jul 18, 2018

Contributor

Workaround:

Replace current poximate positions:

(function(H) {
  H.Legend.prototype.proximatePositions = function() {
    var chart = this.chart,
      boxes = [],
      alignLeft = this.options.align === 'left';

    H.each(this.allItems, function(item) {
      var lastPoint,
        height,
        useFirstPoint = alignLeft;

      if (item.xAxis && item.points) {

        if (item.xAxis.options.reversed) {
          useFirstPoint = !useFirstPoint;
        }
        lastPoint = H.find(
          useFirstPoint ?
          item.points :
          item.points.slice(0).reverse(),
          function(item) {
            return H.isNumber(item.plotY);
          }
        );
        height = item.legendGroup.getBBox().height;
        boxes.push({
          target: item.visible ?
            (lastPoint && lastPoint.plotY || item.xAxis.height) - 0.3 * height : chart.plotHeight, // Fix #8638
          size: height,
          item: item
        });
      }
    }, this);
    H.distribute(boxes, chart.plotHeight);
    H.each(boxes, function(box) {
      box.item._legendItemPos[1] =
        chart.plotTop - chart.spacing[0] + box.pos;
    });

  }
})(Highcharts);

Demo: http://jsfiddle.net/BlackLabel/h0py3os9/

Contributor

pawelfus commented Jul 18, 2018

Workaround:

Replace current poximate positions:

(function(H) {
  H.Legend.prototype.proximatePositions = function() {
    var chart = this.chart,
      boxes = [],
      alignLeft = this.options.align === 'left';

    H.each(this.allItems, function(item) {
      var lastPoint,
        height,
        useFirstPoint = alignLeft;

      if (item.xAxis && item.points) {

        if (item.xAxis.options.reversed) {
          useFirstPoint = !useFirstPoint;
        }
        lastPoint = H.find(
          useFirstPoint ?
          item.points :
          item.points.slice(0).reverse(),
          function(item) {
            return H.isNumber(item.plotY);
          }
        );
        height = item.legendGroup.getBBox().height;
        boxes.push({
          target: item.visible ?
            (lastPoint && lastPoint.plotY || item.xAxis.height) - 0.3 * height : chart.plotHeight, // Fix #8638
          size: height,
          item: item
        });
      }
    }, this);
    H.distribute(boxes, chart.plotHeight);
    H.each(boxes, function(box) {
      box.item._legendItemPos[1] =
        chart.plotTop - chart.spacing[0] + box.pos;
    });

  }
})(Highcharts);

Demo: http://jsfiddle.net/BlackLabel/h0py3os9/

@VBIManonmaniM

This comment has been minimized.

Show comment
Hide comment
@VBIManonmaniM

VBIManonmaniM Jul 18, 2018

@pawelfus Thank you for your reply, When this fix will release.

VBIManonmaniM commented Jul 18, 2018

@pawelfus Thank you for your reply, When this fix will release.

@pawelfus pawelfus self-assigned this Jul 19, 2018

pawelfus added a commit that referenced this issue Jul 19, 2018

@pawelfus

This comment has been minimized.

Show comment
Hide comment
@pawelfus

pawelfus Jul 19, 2018

Contributor

Just added PR with fix, if this will get merged into master, then it will be part of v6.1.2 release.

Contributor

pawelfus commented Jul 19, 2018

Just added PR with fix, if this will get merged into master, then it will be part of v6.1.2 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment