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

Function dataset

src/core/core.interaction.js:306–324  ·  view source on GitHub ↗

* Returns items in the same dataset. If the options.intersect parameter is true, we only return items if we intersect something * If the options.intersect is false, we find the nearest item and return the items in that dataset * @function Chart.Interaction.modes.dataset * @param {Chart} cha

(chart, e, options, useFinalPosition)

Source from the content-addressed store, hash-verified

304 * @return {InteractionItem[]} - items that are found
305 */
306 dataset(chart, e, options, useFinalPosition) {
307 const position = getRelativePosition(e, chart);
308 const axis = options.axis || 'xy';
309 const includeInvisible = options.includeInvisible || false;
310 let items = options.intersect
311 ? getIntersectItems(chart, position, axis, useFinalPosition, includeInvisible) :
312 getNearestItems(chart, position, axis, false, useFinalPosition, includeInvisible);
313
314 if (items.length > 0) {
315 const datasetIndex = items[0].datasetIndex;
316 const data = chart.getDatasetMeta(datasetIndex).data;
317 items = [];
318 for (let i = 0; i < data.length; ++i) {
319 items.push({element: data[i], datasetIndex, index: i});
320 }
321 }
322
323 return items;
324 },
325
326 /**
327 * Point mode returns all elements that hit test based on the event position

Callers

nothing calls this directly

Calls 4

getRelativePositionFunction · 0.85
getIntersectItemsFunction · 0.85
getNearestItemsFunction · 0.85
getDatasetMetaMethod · 0.80

Tested by

no test coverage detected