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

Module connection problem #13

Closed
magistr4815 opened this issue Jun 10, 2020 · 4 comments
Closed

Module connection problem #13

magistr4815 opened this issue Jun 10, 2020 · 4 comments

Comments

@magistr4815
Copy link

Hey. I use npm and vue-js. I connected your plugin like this:

import Vue from 'vue';
import HighchartsVue from 'highcharts-vue';
import Highcharts from 'highcharts/highcharts';
import HighchartTooltipDelay from 'highcharts-tooltip-delay';

HighchartTooltipDelay(Highcharts);

Vue.use(HighchartsVue, { highcharts: Highcharts });

// init vue ...

But I get the error: IMG HERE

tooltip-delay.dist.js:47 Uncaught ReferenceError: Highcharts is not defined
    at Object.../node_modules/highcharts-tooltip-delay/tooltip-delay.dist.js ...

Living example here

Connecting other plugins in the same way works fine!
What am I doing wrong? Thanks in advance!

@magistr4815
Copy link
Author

magistr4815 commented Jun 18, 2020

highchartsTooltipDelay.js

// https://github.com/rudovjan/highcharts-tooltip-delay
// Переделал под нормальный highcharts plugin

export default function (H) {
  const timerId = {};

  const generatePointsUniqueKey = (points) => {
    const generatePointKey = (point) => {
      return point.category + ' ' + point.series.name + ': ' + point.x + ' ' + point.y;
    };

    const result = points.map(generatePointKey).join(', ');

    return result;
  };

  H.wrap(H.Tooltip.prototype, 'refresh', function (proceed) {
    let seriesName;

    if (Array.isArray(arguments[1])) {
      // Can be array in case that, it's shared tooltip
      seriesName = generatePointsUniqueKey(arguments[1]);
    } else {
      seriesName = arguments[1].series.name;
    }

    const delayForDisplay = this.chart.options.tooltip.delayForDisplay ? this.chart.options.tooltip.delayForDisplay : 1000;

    if (timerId[seriesName]) {
      clearTimeout(timerId[seriesName]);
      delete timerId[seriesName];
    }

    timerId[seriesName] = window.setTimeout(function () {
      const pointOrPoints = this.refreshArguments[0];

      if (pointOrPoints === this.chart.hoverPoint || $.inArray(this.chart.hoverPoint, pointOrPoints) > -1) {
        proceed.apply(this.tooltip, this.refreshArguments);
      }
    }.bind({
      refreshArguments: Array.prototype.slice.call(arguments, 1),
      chart: this.chart,
      tooltip: this,
    }), delayForDisplay);
  });
}

index.js

import Highcharts from 'highcharts/highcharts';
import HighchartsTooltipDelay from './highchartsTooltipDelay';

HighchartsTooltipDelay(Highcharts);

I fixed it like that. I got the code from the function that was being executed and put it in a separate file! It is necessary that the author of the repository corrects this and makes a normal plug-in for the chart.

But there is a problem, you have to be connected JQuery - "$.inArray".

@rudovjan
Copy link
Owner

Hi @magistr4815 sorry for very late answer. Will take a look.

@rudovjan
Copy link
Owner

It looks like a lot changed in world of Highcharts

@rudovjan rudovjan pinned this issue Jul 22, 2020
rudovjan added a commit that referenced this issue Jul 22, 2020
#13 - Make it modular + remove jQuery dependency
@rudovjan
Copy link
Owner

Please take a look on new version, it should help.

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

No branches or pull requests

2 participants