Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/events.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {callback} from 'chart.js/helpers';
import {isFunction, callback} from 'chart.js/helpers';
import {getElements} from './interaction';
import {loadHooks} from './helpers';

Expand All @@ -22,19 +22,19 @@ export function updateListeners(chart, state, options) {
state._getElements = getElements; // for testing

moveHooks.forEach(hook => {
if (typeof options[hook] === 'function') {
if (isFunction(options[hook])) {
state.moveListened = true;
}
});

if (!state.listened || !state.moveListened) {
state.annotations.forEach(scope => {
if (!state.listened && typeof scope.click === 'function') {
if (!state.listened && isFunction(scope.click)) {
state.listened = true;
}
if (!state.moveListened) {
moveHooks.forEach(hook => {
if (typeof scope[hook] === 'function') {
if (isFunction(scope[hook])) {
state.listened = true;
state.moveListened = true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/helpers.options.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isObject, valueOrDefault, defined} from 'chart.js/helpers';
import {isObject, isFunction, valueOrDefault, defined} from 'chart.js/helpers';
import {clamp} from './helpers.core';

const isPercentString = (s) => typeof s === 'string' && s.endsWith('%');
Expand Down Expand Up @@ -96,7 +96,7 @@ export function isBoundToPoint(options) {
export function loadHooks(options, hooks, hooksContainer) {
let activated = false;
hooks.forEach(hook => {
if (typeof options[hook] === 'function') {
if (isFunction(options[hook])) {
activated = true;
hooksContainer[hook] = options[hook];
} else if (defined(hooksContainer[hook])) {
Expand Down
4 changes: 2 additions & 2 deletions src/hooks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {callback} from 'chart.js/helpers';
import {isFunction, callback} from 'chart.js/helpers';
import {loadHooks} from './helpers';

/**
Expand All @@ -22,7 +22,7 @@ export function updateHooks(chart, state, options) {
visibleElements.forEach(scope => {
if (!state.hooked) {
elementHooks.forEach(hook => {
if (typeof scope.options[hook] === 'function') {
if (isFunction(scope.options[hook])) {
state.hooked = true;
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/scale.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isFinite, valueOrDefault, defined} from 'chart.js/helpers';
import {isFinite, isFunction, valueOrDefault, defined} from 'chart.js/helpers';
import {retrieveScaleID} from './helpers';

/**
Expand All @@ -16,7 +16,7 @@ export function adjustScaleRange(chart, scale, annotations) {
const range = getScaleLimits(chart.scales, scale, annotations);
let changed = changeScaleLimit(scale, range, 'min', 'suggestedMin');
changed = changeScaleLimit(scale, range, 'max', 'suggestedMax') || changed;
if (changed && typeof scale.handleTickRangeOptions === 'function') {
if (changed && isFunction(scale.handleTickRangeOptions)) {
scale.handleTickRangeOptions();
}
}
Expand Down