Skip to content
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

categoryInCategory: Highcharts is not defined #13722

Closed
shashank1010 opened this issue Jun 15, 2020 · 4 comments · Fixed by #13802
Closed

categoryInCategory: Highcharts is not defined #13722

shashank1010 opened this issue Jun 15, 2020 · 4 comments · Fixed by #13802
Assignees

Comments

@shashank1010
Copy link

Expected behaviour

categoryInCategory should work when highcharts is called as a module instead of loading it with a script tag

Actual behaviour

ERROR ReferenceError: Highcharts is not defined
at e.adjustForMissingColumns (highcharts.src.js:37159)
at eval (highcharts.src.js:37260)
at Array.forEach ()
at e.translate (highcharts.src.js:37220)
at eval (highcharts.src.js:26579)
at Array.forEach ()
at C.renderSeries (highcharts.src.js:26578)
at C.render (highcharts.src.js:26685)
at C.firstRender (highcharts.src.js:26891)
at C.eval (highcharts.src.js:25296)

Live demo with steps to reproduce

https://stackblitz.com/edit/highcharts-centerincategory

Product version

8.1.1

Affected browser(s)

All browsers when Highcharts has been added by npm.
using require('highcharts') or import * as Highcharts from 'highcharts'

@highsoft-bot highsoft-bot added this to To do in Development-Flow Jun 15, 2020
@sebastianbochan
Copy link
Contributor

Hi @shashank1010,
Thank you for reporting. The issue has been already reported and fixed on the master branch.

Im closing the ticket as duplicate of #13710

@shashank1010
Copy link
Author

@sebastianbochan The issue still exists in the above usecase.
Please have a look. I have updated the Highcharts dependency in the demo.

@raf18seb Request you to follow this if you can.

@raf18seb
Copy link
Contributor

raf18seb commented Jun 19, 2020

@shashank1010 we are aware of it, it is already being fixing. This is a duplicate of #13710, please subscribe and follow in there so we can keep all the comments in one ticket.

@goransle
Copy link
Member

@shashank1010 A fix is now on the way. In the mean time, here is a workaround if you prefer not to use 8.1.0:

// Workaround for https://github.com/highcharts/highcharts/issues/13722
(function(H) {
  H.seriesTypes.column.prototype.adjustForMissingColumns = function(
    x,
    pointWidth,
    point,
    metrics
  ) {
    var _this = this;
    var stacking = this.options.stacking;
    if (!point.isNull && metrics.columnCount > 1) {
      var indexInCategory_1 = 0;
      var totalInCategory_1 = 0;

      H.objectEach(this.yAxis.stacking && this.yAxis.stacking.stacks, function(
        stack
      ) {
        if (typeof point.x === "number") {
          var stackItem = stack[point.x.toString()];
          if (stackItem) {
            var pointValues = stackItem.points[_this.index],
              total = stackItem.total;
            if (stacking) {
              if (pointValues) {
                indexInCategory_1 = totalInCategory_1;
              }
              if (stackItem.hasValidPoints) {
                totalInCategory_1++;
              }
            } else if (H.isArray(pointValues)) {
              indexInCategory_1 = pointValues[1];
              totalInCategory_1 = total || 0;
            }
          }
        }
      });
      var boxWidth = (totalInCategory_1 - 1) * metrics.paddedWidth + pointWidth;
      x =
        (point.plotX || 0) +
        boxWidth / 2 -
        pointWidth -
        indexInCategory_1 * metrics.paddedWidth;
    }
    return x;
  };
})(Highcharts);

Workaround applied on stackblitz

Development-Flow automation moved this from To do to Done Jul 1, 2020
@Izothep Izothep removed this from Done in Development-Flow Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants