MCPcopy
hub / github.com/chartjs/Chart.js / getDistanceMetricForAxis

Function getDistanceMetricForAxis

src/core/core.interaction.js:94–103  ·  view source on GitHub ↗

* Get a distance metric function for two points based on the * axis mode setting * @param {string} axis - the axis mode. x|y|xy|r

(axis)

Source from the content-addressed store, hash-verified

92 * @param {string} axis - the axis mode. x|y|xy|r
93 */
94function getDistanceMetricForAxis(axis) {
95 const useX = axis.indexOf('x') !== -1;
96 const useY = axis.indexOf('y') !== -1;
97
98 return function(pt1, pt2) {
99 const deltaX = useX ? Math.abs(pt1.x - pt2.x) : 0;
100 const deltaY = useY ? Math.abs(pt1.y - pt2.y) : 0;
101 return Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2));
102 };
103}
104
105/**
106 * Helper function to get the items that intersect the event position

Callers 1

getNearestCartesianItemsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…