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

trackByArea doesn't work with coloredarea type #31

Open
genzgd opened this issue Aug 2, 2020 · 1 comment
Open

trackByArea doesn't work with coloredarea type #31

genzgd opened this issue Aug 2, 2020 · 1 comment
Labels

Comments

@genzgd
Copy link

genzgd commented Aug 2, 2020

Pretty much what the title says. If I have a regular area chart I can capture a click event in the "area" plot by setting series.trackByArea to true. Using this plugin and the coloredarea bype, only clicks on the point actually fire the event.

@pawelfus
Copy link
Collaborator

pawelfus commented Aug 3, 2020

Thanks for reporting the issue @genzgd

Workaorund:
Demo: https://jsfiddle.net/BlackLabel/tg58gc6x/238/
Plugin:

  Highcharts.seriesTypes.coloredarea.prototype.getGraphPath = function() {
    var series = this,
      graphPath = [],
      segmentPath,
      singlePoints = []; // used in drawTracker
    // Divide into segments and build graph and area paths

    Highcharts.seriesTypes.area.prototype.getGraphPath.call(this);

    // this.areaPath = [];
    Highcharts.each(series.segments, function(segment) {
      segmentPath = series.getSegmentPath(segment.points);
      // add the segment to the graph, or a single point for tracking
      if (segment.points.length > 1) {
        graphPath.push([segmentPath, segment.color]);
      } else {
        singlePoints.push(segment.points);
      }
    });

    // Record it for use in drawGraph and drawTracker, and return graphPath
    series.singlePoints = singlePoints;
    series.graphPath = graphPath;
    return graphPath;
  };

@pawelfus pawelfus added the bug label Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants