Permalink
Browse files

Fixed #6231, added findNearestPointBy option to series.

  • Loading branch information...
oysteinmoseng committed Mar 29, 2017
1 parent 2a2092e commit 956ff1d01e764c3f47dffccb2945cbcfb0395da4
Showing with 15 additions and 10 deletions.
  1. +1 −1 js/parts-more/Polar.js
  2. +5 −1 js/parts/Pointer.js
  3. +1 −1 js/parts/ScatterSeries.js
  4. +8 −7 js/parts/Series.js
@@ -143,7 +143,7 @@ wrap(seriesProto, 'buildKDTree', function (proceed) {
if (this.kdByAngle) {
this.searchPoint = this.searchPointByAngle;
} else {
this.kdDimensions = 2;
this.options.findNearestPointBy = 'xy';
}
}
proceed.apply(this);
@@ -164,7 +164,11 @@ H.Pointer.prototype = {
noSharedTooltip = s.noSharedTooltip && shared;
directTouch = !shared && s.directTouch;
if (s.visible && !noSharedTooltip && !directTouch && pick(s.options.enableMouseTracking, true)) { // #3821
kdpointT = s.searchPoint(e, !noSharedTooltip && s.kdDimensions === 1); // #3828
// #3828
kdpointT = s.searchPoint(
e,
!noSharedTooltip && s.options.findNearestPointBy.indexOf('y') < 0
);
if (kdpointT && kdpointT.series) { // Point.series becomes null when reset and before redraw (#5197)
kdpoints.push(kdpointT);
}
@@ -15,6 +15,7 @@ var Series = H.Series,
*/
seriesType('scatter', 'line', {
lineWidth: 0,
findNearestPointBy: 'xy',
marker: {
enabled: true // Overrides auto-enabling in line series (#3647)
},
@@ -38,7 +39,6 @@ seriesType('scatter', 'line', {
noSharedTooltip: true,
trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
takeOrdinalPosition: false, // #2342
kdDimensions: 2,
drawGraph: function () {
if (this.options.lineWidth) {
Series.prototype.drawGraph.call(this);
@@ -169,9 +169,9 @@ H.Series = H.seriesType('line', null, { // base series options
//valuePrefix: '',
//ySuffix: ''
//}
turboThreshold: 1000
turboThreshold: 1000,
// zIndex: null
findNearestPointBy: 'x' // docs
}, /** @lends Series.prototype */ {
isCartesian: true,
@@ -1931,7 +1931,6 @@ H.Series = H.seriesType('line', null, { // base series options
* KD Tree && PointSearching Implementation
*/
kdDimensions: 1,
kdAxisArray: ['clientX', 'plotY'],
searchPoint: function (e, compareX) {
@@ -1958,7 +1957,8 @@ H.Series = H.seriesType('line', null, { // base series options
this.buildingKdTree = true;
var series = this,
dimensions = series.kdDimensions;
dimensions = series.options.findNearestPointBy.indexOf('y') > -1 ?
2 : 1;
// Internal function
function _kdtree(points, depth, dimensions) {
@@ -2010,7 +2010,9 @@ H.Series = H.seriesType('line', null, { // base series options
var series = this,
kdX = this.kdAxisArray[0],
kdY = this.kdAxisArray[1],
kdComparer = compareX ? 'distX' : 'dist';
kdComparer = compareX ? 'distX' : 'dist',
kdDimensions = series.options.findNearestPointBy.indexOf('y') > -1 ?
2 : 1;
// Set the one and two dimensional distance on the point object
function setDistance(p1, p2) {
@@ -2060,8 +2062,7 @@ H.Series = H.seriesType('line', null, { // base series options
}
if (this.kdTree) {
return _search(point,
this.kdTree, this.kdDimensions, this.kdDimensions);
return _search(point, this.kdTree, kdDimensions, kdDimensions);
}
}

0 comments on commit 956ff1d

Please sign in to comment.