updates to quad tree impl
Esse commit está contido em:
@@ -195,10 +195,11 @@ module.exports = function(Chart) {
|
||||
|
||||
point._model.skip = point.custom && point.custom.skip ? point.custom.skip : (isNaN(point._model.x) || isNaN(point._model.y));
|
||||
|
||||
// Add to quadtree lookup
|
||||
|
||||
this.removeElementFromQuadTree(point); // remove old quadtree point always
|
||||
if (point._model.radius > 0) {
|
||||
var r = point._model.radius + point._model.borderWidth;
|
||||
this.removeElementFromQuadTree(point); // remove old quadtree point
|
||||
// Add to quadtree lookup if being drawn
|
||||
var r = point._model.radius + point._model.borderWidth + point._model.hitRadius;
|
||||
this.insertElementIntoQuadTree(point, {
|
||||
x: point._model.x - r,
|
||||
y: point._model.y - r,
|
||||
|
||||
@@ -19,7 +19,7 @@ module.exports = function(Chart) {
|
||||
this.chart = instance;
|
||||
|
||||
// Allocate new quadtree
|
||||
this.quadTree = new QuadTree({
|
||||
this.quadTree = new Chart.QuadTree({
|
||||
x: 0,
|
||||
y: 0,
|
||||
width: this.chart.width,
|
||||
@@ -339,22 +339,8 @@ module.exports = function(Chart) {
|
||||
// Get the single element that was clicked on
|
||||
// @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw
|
||||
getElementAtEvent: function(e) {
|
||||
|
||||
var eventPosition = helpers.getRelativePosition(e, this.chart);
|
||||
var elementsArray = [];
|
||||
|
||||
helpers.each(this.data.datasets, function(dataset, datasetIndex) {
|
||||
if (helpers.isDatasetVisible(dataset)) {
|
||||
helpers.each(dataset.metaData, function(element, index) {
|
||||
if (element.inRange(eventPosition.x, eventPosition.y)) {
|
||||
elementsArray.push(element);
|
||||
return elementsArray;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return elementsArray;
|
||||
var elements = this.getElementsAtEvent(e);
|
||||
return elements.length ? [elements[0]] : [];
|
||||
},
|
||||
|
||||
getElementsAtEvent: function(e) {
|
||||
@@ -424,13 +410,8 @@ module.exports = function(Chart) {
|
||||
},
|
||||
|
||||
getDatasetAtEvent: function(e) {
|
||||
var elementsArray = this.getElementAtEvent(e);
|
||||
|
||||
if (elementsArray.length > 0) {
|
||||
elementsArray = this.data.datasets[elementsArray[0]._datasetIndex].metaData;
|
||||
}
|
||||
|
||||
return elementsArray;
|
||||
var elements = this.getElementsAtEvent(e);
|
||||
return elements.length ? this.data.datasets[elements[0]._datasetIndex].metaData : [];
|
||||
},
|
||||
|
||||
generateLegend: function generateLegend() {
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário