highcharts
Version:
JavaScript charting framework
1,240 lines (1,237 loc) • 98.7 kB
JavaScript
/**
* @license Highcharts JS v8.0.0 (2019-12-10)
*
* (c) 2009-2019 Torstein Honsi
*
* License: www.highcharts.com/license
*/
'use strict';
(function (factory) {
if (typeof module === 'object' && module.exports) {
factory['default'] = factory;
module.exports = factory;
} else if (typeof define === 'function' && define.amd) {
define('highcharts/modules/draggable-points', ['highcharts'], function (Highcharts) {
factory(Highcharts);
factory.Highcharts = Highcharts;
return factory;
});
} else {
factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
}
}(function (Highcharts) {
var _modules = Highcharts ? Highcharts._modules : {};
function _registerModule(obj, path, args, fn) {
if (!obj.hasOwnProperty(path)) {
obj[path] = fn.apply(null, args);
}
}
_registerModule(_modules, 'modules/draggable-points.src.js', [_modules['parts/Globals.js'], _modules['parts/Utilities.js']], function (H, U) {
/* *
*
* (c) 2009-2019 Highsoft AS
*
* Authors: Øystein Moseng, Torstein Hønsi, Jon A. Nygård
*
* License: www.highcharts.com/license
*
* !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
*
* */
/**
* Current drag and drop position.
*
* @interface Highcharts.DragDropPositionObject
*/ /**
* Chart x position
* @name Highcharts.DragDropPositionObject#chartX
* @type {number}
*/ /**
* Chart y position
* @name Highcharts.DragDropPositionObject#chartY
* @type {number}
*/ /**
* Drag and drop guide box.
* @name Highcharts.DragDropPositionObject#guideBox
* @type {Highcharts.BBoxObject|undefined}
*/ /**
* Updated point data.
* @name Highcharts.DragDropPositionObject#points
* @type {Highcharts.Dictionary<Highcharts.Dictionary<number>>}
*/ /**
* Delta of previous x position.
* @name Highcharts.DragDropPositionObject#prevdX
* @type {number|undefined}
*/ /**
* Delta of previous y position.
* @name Highcharts.DragDropPositionObject#prevdY
* @type {number|undefined}
*/
/**
* Function callback to execute while series points are dragged. Return false to
* stop the default drag action.
*
* @callback Highcharts.PointDragCallbackFunction
*
* @param {Highcharts.Point} this
* Point where the event occured.
*
* @param {Highcharts.PointDragEventObject} event
* Event arguments.
*/
/**
* Contains information about a points new values.
*
* @interface Highcharts.PointDragDropObject
*/ /**
* New values.
* @name Highcharts.PointDragDropObject#newValues
* @type {Highcharts.Dictionary<number>}
*/ /**
* Updated point.
* @name Highcharts.PointDragDropObject#point
* @type {Highcharts.Point}
*/
/**
* Contains common information for a drag event on series points.
*
* @interface Highcharts.PointDragEventObject
*/ /**
* New point after drag if only a single one.
* @name Highcharts.PointDropEventObject#newPoint
* @type {Highcharts.PointDragDropObject|undefined}
*/ /**
* New point id after drag if only a single one.
* @name Highcharts.PointDropEventObject#newPointId
* @type {string|undefined}
*/ /**
* New points during drag.
* @name Highcharts.PointDragEventObject#newPoints
* @type {Highcharts.Dictionary<Highcharts.PointDragDropObject>}
*/ /**
* Original data.
* @name Highcharts.PointDragEventObject#origin
* @type {Highcharts.DragDropPositionObject}
*/ /**
* Prevent default drag action.
* @name Highcharts.PointDragEventObject#preventDefault
* @type {Function}
*/ /**
* Target point that caused the event.
* @name Highcharts.PointDragEventObject#target
* @type {Highcharts.Point}
*/ /**
* Event type.
* @name Highcharts.PointDragEventObject#type
* @type {"drag"}
*/
/**
* Function callback to execute when a series point is dragged.
*
* @callback Highcharts.PointDragStartCallbackFunction
*
* @param {Highcharts.Point} this
* Point where the event occured.
*
* @param {Highcharts.PointDragStartEventObject} event
* Event arguments.
*/
/**
* Contains common information for a drag event on series point.
*
* @interface Highcharts.PointDragStartEventObject
* @extends global.MouseEvent
*/ /**
* Data property being dragged.
* @name Highcharts.PointDragStartEventObject#updateProp
* @type {string|undefined}
*/
/**
* Function callback to execute when series points are dropped.
*
* @callback Highcharts.PointDropCallbackFunction
*
* @param {Highcharts.Point} this
* Point where the event occured.
*
* @param {Highcharts.PointDropEventObject} event
* Event arguments.
*/
/**
* Contains common information for a drop event on series points.
*
* @interface Highcharts.PointDropEventObject
*/ /**
* New point after drop if only a single one.
* @name Highcharts.PointDropEventObject#newPoint
* @type {Highcharts.PointDragDropObject|undefined}
*/ /**
* New point id after drop if only a single one.
* @name Highcharts.PointDropEventObject#newPointId
* @type {string|undefined}
*/ /**
* New points after drop.
* @name Highcharts.PointDropEventObject#newPoints
* @type {Highcharts.Dictionary<Highcharts.PointDragDropObject>}
*/ /**
* Number of new points.
* @name Highcharts.PointDropEventObject#numNewPoints
* @type {number}
*/ /**
* Original data.
* @name Highcharts.PointDropEventObject#origin
* @type {Highcharts.DragDropPositionObject}
*/ /**
* Prevent default drop action.
* @name Highcharts.PointDropEventObject#preventDefault
* @type {Function}
*/ /**
* Target point that caused the event.
* @name Highcharts.PointDropEventObject#target
* @type {Highcharts.Point}
*/ /**
* Event type.
* @name Highcharts.PointDropEventObject#type
* @type {"drop"}
*/
var clamp = U.clamp,
objectEach = U.objectEach,
pick = U.pick;
var addEvent = H.addEvent,
merge = H.merge,
seriesTypes = H.seriesTypes;
/**
* Flip a side property, used with resizeRect. If input side is "left", return
* "right" etc.
*
* @private
* @function flipResizeSide
*
* @param {string} side
* Side prop to flip. Can be `left`, `right`, `top` or `bottom`.
*
* @return {"bottom"|"left"|"right"|"top"|undefined}
* The flipped side.
*/
function flipResizeSide(side) {
return {
left: 'right',
right: 'left',
top: 'bottom',
bottom: 'top'
}[side];
}
/* @todo
Add drag/drop support to specific data props for different series types.
The dragDrop.draggableX/Y user options on series enable/disable all of these per
irection unless they are specifically set in options using
dragDrop.{optionName}. If the prop does not specify an optionName here, it can
only be enabled/disabled by the user with draggableX/Y.
Supported options for each prop:
optionName: User option in series.dragDrop that enables/disables
dragging this prop.
axis: Can be 'x' or 'y'. Whether this prop is linked to x or y axis.
move: Whether or not this prop should be updated when moving points.
resize: Whether or not to draw a drag handle and allow user to drag and
update this prop by itself.
beforeResize: Hook to perform tasks before a resize is made. Gets
the guide box, the new points values, and the point as args.
resizeSide: Which side of the guide box to resize when dragging the
handle. Can be "left", "right", "top", "bottom". Chart.inverted is
handled automatically. Can also be a function, taking the new point
values as parameter, as well as the point, and returning a string
with the side.
propValidate: Function that takes the prop value and the point as
arguments, and returns true if the prop value is valid, false if
not. It is used to prevent e.g. resizing "low" above "high".
handlePositioner: For resizeable props, return 0,0 in SVG plot coords of
where to place the dragHandle. Gets point as argument. Should return
object with x and y properties.
handleFormatter: For resizeable props, return the path of the drag
handle as an SVG path array. Gets the point as argument. The handle
is translated according to handlePositioner.
handleOptions: Options to merge with the default handle options.
TODO:
- It makes sense to have support for resizing the size of bubbles and
e.g variwide columns. This requires us to support dragging along a
z-axis, somehow computing a relative value from old to new pixel
size.
- Moving maps could be useful, although we would have to compute new
point.path values in order to do it properly (using SVG translate
is easier, but won't update the data).
*/
// 90deg rotated column handle path, used in multiple series types
var horizHandleFormatter = function (point) {
var shapeArgs = point.shapeArgs || point.graphic.getBBox(),
top = shapeArgs.r || 0, // Rounding of bar corners
bottom = shapeArgs.height - top,
centerY = shapeArgs.height / 2;
return [
// Top wick
'M', 0, top,
'L', 0, centerY - 5,
// Circle
'A', 1, 1, 0, 0, 0, 0, centerY + 5,
'A', 1, 1, 0, 0, 0, 0, centerY - 5,
// Bottom wick
'M', 0, centerY + 5,
'L', 0, bottom
];
};
// Line series - only draggableX/Y, no drag handles
var lineDragDropProps = seriesTypes.line.prototype.dragDropProps = {
x: {
axis: 'x',
move: true
},
y: {
axis: 'y',
move: true
}
};
// Flag series - same as line/scatter
if (seriesTypes.flags) {
seriesTypes.flags.prototype.dragDropProps = lineDragDropProps;
}
// Column series - x can be moved, y can only be resized. Note extra
// functionality for handling upside down columns (below threshold).
var columnDragDropProps = seriesTypes.column.prototype.dragDropProps = {
x: {
axis: 'x',
move: true
},
y: {
axis: 'y',
move: false,
resize: true,
// Force guideBox start coordinates
beforeResize: function (guideBox,
pointVals,
point) {
// We need to ensure that guideBox always starts at threshold.
// We flip whether or not we update the top or bottom of the guide
// box at threshold, but if we drag the mouse fast, the top has not
// reached threshold before we cross over and update the bottom.
var threshold = point.series.translatedThreshold,
y = guideBox.attr('y'),
height,
diff;
if (pointVals.y >= point.series.options.threshold || 0) {
// Above threshold - always set height to hit the threshold
height = guideBox.attr('height');
diff = threshold ?
threshold - (y + height) :
0;
guideBox.attr({
height: Math.max(0, Math.round(height + diff))
});
}
else {
// Below - always set y to start at threshold
guideBox.attr({
y: Math.round(y + (threshold ? threshold - y : 0))
});
}
},
// Flip the side of the resize handle if column is below threshold.
// Make sure we remove the handle on the other side.
resizeSide: function (pointVals, point) {
var chart = point.series.chart,
dragHandles = chart.dragHandles,
side = pointVals.y >= (point.series.options.threshold || 0) ?
'top' : 'bottom',
flipSide = flipResizeSide(side);
// Force remove handle on other side
if (dragHandles[flipSide]) {
dragHandles[flipSide].destroy();
delete dragHandles[flipSide];
}
return side;
},
// Position handle at bottom if column is below threshold
handlePositioner: function (point) {
var bBox = point.shapeArgs || point.graphic.getBBox();
return {
x: bBox.x,
y: point.y >= (point.series.options.threshold || 0) ?
bBox.y : bBox.y + bBox.height
};
},
// Horizontal handle
handleFormatter: function (point) {
var shapeArgs = point.shapeArgs,
radius = shapeArgs.r || 0, // Rounding of bar corners
centerX = shapeArgs.width / 2;
return [
// Left wick
'M', radius, 0,
'L', centerX - 5, 0,
// Circle
'A', 1, 1, 0, 0, 0, centerX + 5, 0,
'A', 1, 1, 0, 0, 0, centerX - 5, 0,
// Right wick
'M', centerX + 5, 0,
'L', shapeArgs.width - radius, 0
];
}
}
};
// Bullet graph, x/y same as column, but also allow target to be dragged.
if (seriesTypes.bullet) {
seriesTypes.bullet.prototype.dragDropProps = {
x: columnDragDropProps.x,
y: columnDragDropProps.y,
/**
* Allow target value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.bullet.dragDrop.draggableTarget
*/
target: {
optionName: 'draggableTarget',
axis: 'y',
move: true,
resize: true,
resizeSide: 'top',
handlePositioner: function (point) {
var bBox = point.targetGraphic.getBBox();
return {
x: point.barX,
y: bBox.y + bBox.height / 2
};
},
handleFormatter: columnDragDropProps.y.handleFormatter
}
};
}
// Columnrange series - move x, resize or move low/high
if (seriesTypes.columnrange) {
seriesTypes.columnrange.prototype.dragDropProps = {
x: {
axis: 'x',
move: true
},
/**
* Allow low value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.columnrange.dragDrop.draggableLow
*/
low: {
optionName: 'draggableLow',
axis: 'y',
move: true,
resize: true,
resizeSide: 'bottom',
handlePositioner: function (point) {
var bBox = point.shapeArgs || point.graphic.getBBox();
return {
x: bBox.x,
y: bBox.y + bBox.height
};
},
handleFormatter: columnDragDropProps.y.handleFormatter,
propValidate: function (val, point) {
return val <= point.high;
}
},
/**
* Allow high value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.columnrange.dragDrop.draggableHigh
*/
high: {
optionName: 'draggableHigh',
axis: 'y',
move: true,
resize: true,
resizeSide: 'top',
handlePositioner: function (point) {
var bBox = point.shapeArgs || point.graphic.getBBox();
return {
x: bBox.x,
y: bBox.y
};
},
handleFormatter: columnDragDropProps.y.handleFormatter,
propValidate: function (val, point) {
return val >= point.low;
}
}
};
}
// Boxplot series - move x, resize or move low/q1/q3/high
if (seriesTypes.boxplot) {
seriesTypes.boxplot.prototype.dragDropProps = {
x: columnDragDropProps.x,
/**
* Allow low value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.boxplot.dragDrop.draggableLow
*/
low: {
optionName: 'draggableLow',
axis: 'y',
move: true,
resize: true,
resizeSide: 'bottom',
handlePositioner: function (point) {
return {
x: point.shapeArgs.x,
y: point.lowPlot
};
},
handleFormatter: columnDragDropProps.y.handleFormatter,
propValidate: function (val, point) {
return val <= point.q1;
}
},
/**
* Allow Q1 value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.boxplot.dragDrop.draggableQ1
*/
q1: {
optionName: 'draggableQ1',
axis: 'y',
move: true,
resize: true,
resizeSide: 'bottom',
handlePositioner: function (point) {
return {
x: point.shapeArgs.x,
y: point.q1Plot
};
},
handleFormatter: columnDragDropProps.y.handleFormatter,
propValidate: function (val, point) {
return val <= point.median && val >= point.low;
}
},
median: {
// Median can not be dragged individually, just move the whole
// point for this.
axis: 'y',
move: true
},
/**
* Allow Q3 value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.boxplot.dragDrop.draggableQ3
*/
q3: {
optionName: 'draggableQ3',
axis: 'y',
move: true,
resize: true,
resizeSide: 'top',
handlePositioner: function (point) {
return {
x: point.shapeArgs.x,
y: point.q3Plot
};
},
handleFormatter: columnDragDropProps.y.handleFormatter,
propValidate: function (val, point) {
return val <= point.high && val >= point.median;
}
},
/**
* Allow high value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.boxplot.dragDrop.draggableHigh
*/
high: {
optionName: 'draggableHigh',
axis: 'y',
move: true,
resize: true,
resizeSide: 'top',
handlePositioner: function (point) {
return {
x: point.shapeArgs.x,
y: point.highPlot
};
},
handleFormatter: columnDragDropProps.y.handleFormatter,
propValidate: function (val, point) {
return val >= point.q3;
}
}
};
}
// OHLC series - move x, resize or move open/high/low/close
if (seriesTypes.ohlc) {
seriesTypes.ohlc.prototype.dragDropProps = {
x: columnDragDropProps.x,
/**
* Allow low value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.ohlc.dragDrop.draggableLow
*/
low: {
optionName: 'draggableLow',
axis: 'y',
move: true,
resize: true,
resizeSide: 'bottom',
handlePositioner: function (point) {
return {
x: point.shapeArgs.x,
y: point.plotLow
};
},
handleFormatter: columnDragDropProps.y.handleFormatter,
propValidate: function (val, point) {
return val <= point.open && val <= point.close;
}
},
/**
* Allow high value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.ohlc.dragDrop.draggableHigh
*/
high: {
optionName: 'draggableHigh',
axis: 'y',
move: true,
resize: true,
resizeSide: 'top',
handlePositioner: function (point) {
return {
x: point.shapeArgs.x,
y: point.plotHigh
};
},
handleFormatter: columnDragDropProps.y.handleFormatter,
propValidate: function (val, point) {
return val >= point.open && val >= point.close;
}
},
/**
* Allow open value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.ohlc.dragDrop.draggableOpen
*/
open: {
optionName: 'draggableOpen',
axis: 'y',
move: true,
resize: true,
resizeSide: function (point) {
return point.open >= point.close ? 'top' : 'bottom';
},
handlePositioner: function (point) {
return {
x: point.shapeArgs.x,
y: point.plotOpen
};
},
handleFormatter: columnDragDropProps.y.handleFormatter,
propValidate: function (val, point) {
return val <= point.high && val >= point.low;
}
},
/**
* Allow close value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.ohlc.dragDrop.draggableClose
*/
close: {
optionName: 'draggableClose',
axis: 'y',
move: true,
resize: true,
resizeSide: function (point) {
return point.open >= point.close ? 'bottom' : 'top';
},
handlePositioner: function (point) {
return {
x: point.shapeArgs.x,
y: point.plotClose
};
},
handleFormatter: columnDragDropProps.y.handleFormatter,
propValidate: function (val, point) {
return val <= point.high && val >= point.low;
}
}
};
}
// Arearange series - move x, resize or move low/high
if (seriesTypes.arearange) {
var columnrangeDragDropProps = seriesTypes.columnrange.prototype.dragDropProps,
// Use a circle covering the marker as drag handle
arearangeHandleFormatter = function (point) {
var radius = point.graphic ?
point.graphic.getBBox().width / 2 + 1 :
4;
return [
'M', 0 - radius, 0,
'a', radius, radius, 0, 1, 0, radius * 2, 0,
'a', radius, radius, 0, 1, 0, radius * -2, 0
];
};
seriesTypes.arearange.prototype.dragDropProps = {
x: columnrangeDragDropProps.x,
/**
* Allow low value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.arearange.dragDrop.draggableLow
*/
low: {
optionName: 'draggableLow',
axis: 'y',
move: true,
resize: true,
resizeSide: 'bottom',
handlePositioner: function (point) {
var bBox = point.lowerGraphic && point.lowerGraphic.getBBox();
return bBox ? {
x: bBox.x + bBox.width / 2,
y: bBox.y + bBox.height / 2
} : { x: -999, y: -999 };
},
handleFormatter: arearangeHandleFormatter,
propValidate: columnrangeDragDropProps.low.propValidate
},
/**
* Allow high value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.arearange.dragDrop.draggableHigh
*/
high: {
optionName: 'draggableHigh',
axis: 'y',
move: true,
resize: true,
resizeSide: 'top',
handlePositioner: function (point) {
var bBox = point.upperGraphic && point.upperGraphic.getBBox();
return bBox ? {
x: bBox.x + bBox.width / 2,
y: bBox.y + bBox.height / 2
} : { x: -999, y: -999 };
},
handleFormatter: arearangeHandleFormatter,
propValidate: columnrangeDragDropProps.high.propValidate
}
};
}
// Waterfall - mostly as column, but don't show drag handles for sum points
if (seriesTypes.waterfall) {
seriesTypes.waterfall.prototype.dragDropProps = {
x: columnDragDropProps.x,
y: merge(columnDragDropProps.y, {
handleFormatter: function (point) {
return point.isSum || point.isIntermediateSum ? null :
columnDragDropProps.y.handleFormatter(point);
}
})
};
}
// Xrange - resize/move x/x2, and move y
if (seriesTypes.xrange) {
// Handle positioner logic is the same for x and x2 apart from the
// x value. shapeArgs does not take yAxis reversed etc into account, so we
// use axis.toPixels to handle positioning.
var xrangeHandlePositioner = function (point,
xProp) {
var series = point.series,
xAxis = series.xAxis,
yAxis = series.yAxis,
inverted = series.chart.inverted,
// Using toPixels handles axis.reversed, but doesn't take
// chart.inverted into account.
newX = xAxis.toPixels(point[xProp],
true),
newY = yAxis.toPixels(point.y,
true);
// Handle chart inverted
if (inverted) {
newX = xAxis.len - newX;
newY = yAxis.len - newY - point.shapeArgs.height / 2;
}
else {
newY -= point.shapeArgs.height / 2;
}
return {
x: Math.round(newX),
y: Math.round(newY)
};
}, xrangeDragDropProps = seriesTypes.xrange.prototype.dragDropProps = {
y: {
axis: 'y',
move: true
},
/**
* Allow x value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.xrange.dragDrop.draggableX1
*/
x: {
optionName: 'draggableX1',
axis: 'x',
move: true,
resize: true,
resizeSide: 'left',
handlePositioner: function (point) {
return xrangeHandlePositioner(point, 'x');
},
handleFormatter: horizHandleFormatter,
propValidate: function (val, point) {
return val <= point.x2;
}
},
/**
* Allow x2 value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.xrange.dragDrop.draggableX2
*/
x2: {
optionName: 'draggableX2',
axis: 'x',
move: true,
resize: true,
resizeSide: 'right',
handlePositioner: function (point) {
return xrangeHandlePositioner(point, 'x2');
},
handleFormatter: horizHandleFormatter,
propValidate: function (val, point) {
return val >= point.x;
}
}
};
// Gantt - same as xrange, but with aliases
if (seriesTypes.gantt) {
seriesTypes.gantt.prototype.dragDropProps = {
y: xrangeDragDropProps.y,
/**
* Allow start value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.gantt.dragDrop.draggableStart
*/
start: merge(xrangeDragDropProps.x, {
optionName: 'draggableStart',
// Do not allow individual drag handles for milestones
validateIndividualDrag: function (point) {
return !point.milestone;
}
}),
/**
* Allow end value to be dragged individually.
*
* @type {boolean}
* @default true
* @requires modules/draggable-points
* @apioption plotOptions.gantt.dragDrop.draggableEnd
*/
end: merge(xrangeDragDropProps.x2, {
optionName: 'draggableEnd',
// Do not allow individual drag handles for milestones
validateIndividualDrag: function (point) {
return !point.milestone;
}
})
};
}
}
// Don't support certain series types
[
'gauge',
'pie',
'sunburst',
'wordcloud',
'sankey',
'histogram',
'pareto',
'vector',
'windbarb',
'treemap',
'bellcurve',
'sma',
'map',
'mapline'
].forEach(
/**
* @private
* @param {string} type
* Unsupported series type
* @return {void}
*/
function (type) {
if (seriesTypes[type]) {
seriesTypes[type].prototype.dragDropProps = null;
}
});
/**
* The draggable-points module allows points to be moved around or modified in
* the chart. In addition to the options mentioned under the `dragDrop` API
* structure, the module fires three events,
* [point.dragStart](plotOptions.series.point.events.dragStart),
* [point.drag](plotOptions.series.point.events.drag) and
* [point.drop](plotOptions.series.point.events.drop).
*
* @sample highcharts/dragdrop/resize-column
* Draggable column and line series
* @sample highcharts/dragdrop/bar-series
* Draggable bar
* @sample highcharts/dragdrop/drag-bubble
* Draggable bubbles
* @sample highcharts/dragdrop/drag-xrange
* Draggable X range series
*
* @declare Highcharts.SeriesDragDropOptionsObject
* @since 6.2.0
* @requires modules/draggable-points
* @apioption plotOptions.series.dragDrop
*/
/**
* The amount of pixels to drag the pointer before it counts as a drag
* operation. This prevents drag/drop to fire when just clicking or selecting
* points.
*
* @type {number}
* @default 2
* @since 6.2.0
* @apioption plotOptions.series.dragDrop.dragSensitivity
*
* @private
*/
var defaultDragSensitivity = 2;
/**
* Style options for the guide box. The guide box has one state by default, the
* `default` state.
*
* @type {Highcharts.Dictionary<Highcharts.DragDropGuideBoxOptionsObject>}
* @since 6.2.0
* @optionparent plotOptions.series.dragDrop.guideBox
*
* @private
*/
var defaultGuideBoxOptions = {
/**
* Style options for the guide box default state.
*
* @declare Highcharts.DragDropGuideBoxOptionsObject
* @since 6.2.0
*/
'default': {
/**
* CSS class name of the guide box in this state. Defaults to
* `highcharts-drag-box-default`.
*
* @since 6.2.0
*/
className: 'highcharts-drag-box-default',
/**
* Width of the line around the guide box.
*
* @since 6.2.0
*/
lineWidth: 1,
/**
* Color of the border around the guide box.
*
* @type {Highcharts.ColorString}
* @since 6.2.0
*/
lineColor: '#888',
/**
* Guide box fill color.
*
* @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
* @since 6.2.0
*/
color: 'rgba(0, 0, 0, 0.1)',
/**
* Guide box cursor.
*
* @since 6.2.0
*/
cursor: 'move',
/**
* Guide box zIndex.
*
* @since 6.2.0
*/
zIndex: 900
}
};
/**
* Options for the drag handles.
*
* @declare Highcharts.DragDropHandleOptionsObject
* @since 6.2.0
* @optionparent plotOptions.series.dragDrop.dragHandle
*
* @private
*/
var defaultDragHandleOptions = {
/**
* Function to define the SVG path to use for the drag handles. Takes the
* point as argument. Should return an SVG path in array format. The SVG
* path is automatically positioned on the point.
*
* @type {Function}
* @since 6.2.0
* @apioption plotOptions.series.dragDrop.dragHandle.pathFormatter
*/
// pathFormatter: null,
/**
* The mouse cursor to use for the drag handles. By default this is
* intelligently switching between `ew-resize` and `ns-resize` depending on
* the direction the point is being dragged.
*
* @type {string}
* @since 6.2.0
* @apioption plotOptions.series.dragDrop.dragHandle.cursor
*/
// cursor: null,
/**
* The class name of the drag handles. Defaults to `highcharts-drag-handle`.
*
* @since 6.2.0
*/
className: 'highcharts-drag-handle',
/**
* The fill color of the drag handles.
*
* @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
* @since 6.2.0
*/
color: '#fff',
/**
* The line color of the drag handles.
*
* @type {Highcharts.ColorString}
* @since 6.2.0
*/
lineColor: 'rgba(0, 0, 0, 0.6)',
/**
* The line width for the drag handles.
*
* @since 6.2.0
*/
lineWidth: 1,
/**
* The z index for the drag handles.
*
* @since 6.2.0
*/
zIndex: 901
};
/**
* Set the minimum X value the points can be moved to.
*
* @sample {gantt} gantt/dragdrop/drag-gantt
* Limit dragging
* @sample {highcharts} highcharts/dragdrop/drag-xrange
* Limit dragging
*
* @type {number}
* @since 6.2.0
* @apioption plotOptions.series.dragDrop.dragMinX
*/
/**
* Set the maximum X value the points can be moved to.
*
* @sample {gantt} gantt/dragdrop/drag-gantt
* Limit dragging
* @sample {highcharts} highcharts/dragdrop/drag-xrange
* Limit dragging
*
* @type {number}
* @since 6.2.0
* @apioption plotOptions.series.dragDrop.dragMaxX
*/
/**
* Set the minimum Y value the points can be moved to.
*
* @sample {gantt} gantt/dragdrop/drag-gantt
* Limit dragging
* @sample {highcharts} highcharts/dragdrop/drag-xrange
* Limit dragging
*
* @type {number}
* @since 6.2.0
* @apioption plotOptions.series.dragDrop.dragMinY
*/
/**
* Set the maximum Y value the points can be moved to.
*
* @sample {gantt} gantt/dragdrop/drag-gantt
* Limit dragging
* @sample {highcharts} highcharts/dragdrop/drag-xrange
* Limit dragging
*
* @type {number}
* @since 6.2.0
* @apioption plotOptions.series.dragDrop.dragMaxY
*/
/**
* The X precision value to drag to for this series. Set to 0 to disable. By
* default this is disabled, except for category axes, where the default is 1.
*
* @type {number}
* @default 0
* @since 6.2.0
* @apioption plotOptions.series.dragDrop.dragPrecisionX
*/
/**
* The Y precision value to drag to for this series. Set to 0 to disable. By
* default this is disabled, except for category axes, where the default is 1.
*
* @type {number}
* @default 0
* @since 6.2.0
* @apioption plotOptions.series.dragDrop.dragPrecisionY
*/
/**
* Enable dragging in the X dimension.
*
* @type {boolean}
* @since 6.2.0
* @apioption plotOptions.series.dragDrop.draggableX
*/
/**
* Enable dragging in the Y dimension. Note that this is not supported for
* TreeGrid axes (the default axis type in Gantt charts).
*
* @type {boolean}
* @since 6.2.0
* @apioption plotOptions.series.dragDrop.draggableY
*/
/**
* Group the points by a property. Points with the same property value will be
* grouped together when moving.
*
* @sample {gantt} gantt/dragdrop/drag-gantt
* Drag grouped points
* @sample {highcharts} highcharts/dragdrop/drag-xrange
* Drag grouped points
*
* @type {string}
* @since 6.2.0
* @apioption plotOptions.series.dragDrop.groupBy
*/
/**
* Update points as they are dragged. If false, a guide box is drawn to
* illustrate the new point size.
*
* @sample {gantt} gantt/dragdrop/drag-gantt
* liveRedraw disabled
* @sample {highcharts} highcharts/dragdrop/drag-xrange
* liveRedraw disabled
*
* @type {boolean}
* @default true
* @since 6.2.0
* @apioption plotOptions.series.dragDrop.liveRedraw
*/
/**
* Set a key to hold when dragging to zoom the chart. This is useful to avoid
* zooming while moving points. Should be set different than
* [chart.panKey](#chart.panKey).
*
* @type {string}
* @since 6.2.0
* @validvalue ["alt", "ctrl", "meta", "shift"]
* @requires modules/draggable-points
* @apioption chart.zoomKey
*/
/**
* Callback that fires when starting to drag a point. The mouse event object is
* passed in as an argument. If a drag handle is used, `e.updateProp` is set to
* the data property being dragged. The `this` context is the point. See
* [drag and drop options](plotOptions.series.dragDrop).
*
* @sample {highcharts} highcharts/dragdrop/drag-xrange
* Drag events
*
* @type {Highcharts.PointDragStartCallbackFunction}
* @since 6.2.0
* @requires modules/draggable-points
* @apioption plotOptions.series.point.events.dragStart
*/
/**
* Callback that fires while dragging a point. The mouse event is passed in as
* parameter. The original data can be accessed from `e.origin`, and the new
* point values can be accessed from `e.newPoints`. If there is only a single
* point being updated, it can be accessed from `e.newPoint` for simplicity, and
* its ID can be accessed from `e.newPointId`. The `this` context is the point
* being dragged. To stop the default drag action, return false. See
* [drag and drop options](plotOptions.series.dragDrop).
*
* @sample {highcharts} highcharts/dragdrop/drag-xrange
* Drag events
*
* @type {Highcharts.PointDragCallbackFunction}
* @since 6.2.0
* @requires modules/draggable-points
* @apioption plotOptions.series.point.events.drag
*/
/**
* Callback that fires when the point is dropped. The parameters passed are the
* same as for [drag](#plotOptions.series.point.events.drag). To stop the
* default drop action, return false. See
* [drag and drop options](plotOptions.series.dragDrop).
*
* @sample {highcharts} highcharts/dragdrop/drag-xrange
* Drag events
*
* @type {Highcharts.PointDropCallbackFunction}
* @since 6.2.0
* @requires modules/draggable-points
* @apioption plotOptions.series.point.events.drop
*/
/**
* Point specific options for the draggable-points module. Overrides options on
* `s