score:1

Accepted answer

You can overwrite Highcharts.Annotation.prototype.onDrag method:

(function(H) {
    H.Annotation.prototype.onDrag = function(e) {
        if (
            this.chart.isInsidePlot(
                e.chartX - this.chart.plotLeft,
                e.chartY - this.chart.plotTop
            )
        ) {
            var translation = this.mouseMoveToTranslation(e),
                xAxis = this.chart.xAxis[0],
                step = 0.5,
                pxStep = xAxis.toPixels(step) - xAxis.toPixels(0);

            if (!H.defined(this.potentialTranslation)) {
                this.potentialTranslation = 0;
            }

            this.potentialTranslation += translation.x;

            if (Math.abs(this.potentialTranslation) >= pxStep) {
                translation.y = 0;
                translation.x = (this.potentialTranslation > 0) ? pxStep : -pxStep;
                this.potentialTranslation = 0;

                if (this.points.length) {
                    this.translate(translation.x, translation.y);
                } else {
                    this.shapes.forEach(function(shape) {
                        shape.translate(translation.x, translation.y);
                    });
                    this.labels.forEach(function(label) {
                        label.translate(translation.x, translation.y);
                    });
                }
            }

            this.redraw(false);
        }
    }
}(Highcharts));

Live demo: http://jsfiddle.net/BlackLabel/vmon2chx/

Docs: https://www.highcharts.com/docs/extending-highcharts


Related Query

More Query from same tag