Fahad Khan
Fahad Khan

Reputation: 1635

How can I avoid moving flags when mouseovered - highcharts

I have a similar problem as in this fiddle When I mouse over the green circles (which are on same point), they gets move up a bit, how can I make them stay put when hovered over.

Note: adding different series for each is not what I can do.

Thanks for any help.

Upvotes: 1

Views: 77

Answers (1)

Sebastian Bochan
Sebastian Bochan

Reputation: 37578

I prepared you a snippet which overwrite a distance.

 (function (HC) {
    var each = Highcharts.each,
        addEvent = window.HighchartsAdapter.addEvent,
        TrackerMixin = Highcharts.TrackerMixin;

    HC.wrap(HC.seriesTypes.flags.prototype, 'drawTracker', function (proceed) {

        var series = this,
            points = series.points;

        TrackerMixin.drawTrackerPoint.apply(this);

        each(points, function (point) {
            var graphic = point.graphic;
            if (graphic) {
                addEvent(graphic.element, 'mouseover', function () {

                    // Raise this point
                    if (point.stackIndex > 0 && !point.raised) {
                        point._y = graphic.y;
                        graphic.attr({
                            y: point._y
                        });
                        point.raised = true;
                    }

                    // Revert other raised points
                    each(points, function (otherPoint) {
                        if (otherPoint !== point && otherPoint.raised && otherPoint.graphic) {
                            otherPoint.graphic.attr({
                                y: otherPoint._y
                            });
                            otherPoint.raised = false;
                        }
                    });
                });
            }
        });

    });
})(Highcharts);

http://jsfiddle.net/5pXfM/6/

Upvotes: 1

Related Questions