Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add getAnnotations function to plugin and remove _getState private one #892

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
add function for coverage just for interaction
  • Loading branch information
stockiNail committed May 22, 2023
commit 92ecbb5b15f09f3a62b2c852c4ac237774fe19a3
6 changes: 6 additions & 0 deletions src/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {handleEvent, eventHooks, updateListeners} from './events';
import {invokeHook, elementHooks, updateHooks} from './hooks';
import {adjustScaleRange, verifyScaleOptions} from './scale';
import {updateElements, resolveType, isIndexable} from './elements';
import {getElements} from './interaction';
import {annotationTypes} from './types';
import {requireVersion} from './helpers';
import {version} from '../package.json';
Expand Down Expand Up @@ -106,6 +107,11 @@ export default {
return state ? state.elements : [];
},

// only for testing
_getAnnotationElementsAtEventForMode(visibleElements, event, options) {
return getElements(visibleElements, event, options);
},

defaults: {
animations: {
numbers: {
Expand Down
4 changes: 1 addition & 3 deletions test/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import {getElements} from '../src/interaction';

export function getQuadraticXY(t, sx, sy, cp1x, cp1y, ex, ey) {
return {
x: (1 - t) * (1 - t) * sx + 2 * (1 - t) * t * cp1x + t * t * ex,
Expand Down Expand Up @@ -52,7 +50,7 @@ export function getAnnotationElements(chart) {
}

export function getAnnotationInteractedElements(visibleElements, event, options) {
return getElements(visibleElements, event, options);
return window['chartjs-plugin-annotation']._getAnnotationElementsAtEventForMode(visibleElements, event, options);
}

export function scatterChart(xMax, yMax, annotations) {
Expand Down