]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
JSDoc fixes (#7112)
authorBen McCann <322311+benmccann@users.noreply.github.com>
Mon, 17 Feb 2020 19:31:43 +0000 (11:31 -0800)
committerGitHub <noreply@github.com>
Mon, 17 Feb 2020 19:31:43 +0000 (14:31 -0500)
src/core/core.interaction.js
src/core/core.scale.js
src/helpers/helpers.dom.js
src/helpers/helpers.options.js
src/helpers/helpers.segment.js
src/platform/platform.base.js
src/platform/platform.dom.js
src/scales/scale.linearbase.js
src/scales/scale.time.js

index ba73fc909e6e0f9beebb7a00c92421980d29cd5f..d172f1a3553021b9bcfb719fd679cfb20c4102ff 100644 (file)
@@ -50,7 +50,7 @@ function evaluateAllVisibleItems(chart, handler) {
  * @param {object} metaset - the dataset meta
  * @param {string} axis - the axis mide. x|y|xy
  * @param {number} value - the value to find
- * @param {boolean} intersect - should the element intersect
+ * @param {boolean} [intersect] - should the element intersect
  * @returns {{lo:number, hi:number}} indices to search data array between
  */
 function binarySearch(metaset, axis, value, intersect) {
index 35f8fd6dacd5487011d89c6c11a1f853fa5023c6..cb9f42b2977624f9e17e960cb9646cfd2354bd10 100644 (file)
@@ -267,19 +267,19 @@ class Scale extends Element {
                this.paddingRight = undefined;
 
                // scale-specific properties
-               /** @type {string} */
+               /** @type {string=} */
                this.axis = undefined;
-               /** @type {number} */
+               /** @type {number=} */
                this.labelRotation = undefined;
                this.min = undefined;
                this.max = undefined;
                /** @type {object[]} */
                this.ticks = null;
-               /** @type {object[]} */
+               /** @type {object[]|null} */
                this._gridLineItems = null;
-               /** @type {object[]} */
+               /** @type {object[]|null} */
                this._labelItems = null;
-               /** @type {object} */
+               /** @type {object|null} */
                this._labelSizes = null;
                /** @type {number} */
                this._length = undefined;
index e71ff3352d30f41d734f2f113e9bf4773698dbe7..f651cbb75f0091391cf540f83f2f50eaaaabd742 100644 (file)
@@ -39,7 +39,7 @@ function parseMaxStyle(styleValue, node, parentProperty) {
  * @param {HTMLElement} domNode - the node to check the constraint on
  * @param {string} maxStyle - the style that defines the maximum for the direction we are using ('max-width' / 'max-height')
  * @param {string} percentageProperty - property of parent to use when calculating width as a percentage
- * @return {number|undefined} number or undefined if no constraint
+ * @return {number=} number or undefined if no constraint
  * @see {@link https://www.nathanaeljones.com/blog/2013/reading-max-width-cross-browser}
  */
 function getConstraintDimension(domNode, maxStyle, percentageProperty) {
@@ -64,12 +64,12 @@ export function getStyle(el, property) {
                document.defaultView.getComputedStyle(el, null).getPropertyValue(property);
 }
 
-/** @return {number|undefined} number or undefined if no constraint */
+/** @return {number=} number or undefined if no constraint */
 function getConstraintWidth(domNode) {
        return getConstraintDimension(domNode, 'max-width', 'clientWidth');
 }
 
-/** @return {number|undefined} number or undefined if no constraint */
+/** @return {number=} number or undefined if no constraint */
 function getConstraintHeight(domNode) {
        return getConstraintDimension(domNode, 'max-height', 'clientHeight');
 }
index 3969a1c3ddc04088695284ada4088dec2ca1b37b..d38bbb8b76389060ec24769a26c19b39d7441a7f 100644 (file)
@@ -4,7 +4,7 @@ import {isNullOrUndef, isArray, isObject, valueOrDefault} from './helpers.core';
 /**
  * Converts the given font object into a CSS font string.
  * @param {object} font - A font object.
- * @return {string} The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
+ * @return {string|null} The CSS font string. See https://developer.mozilla.org/en-US/docs/Web/CSS/font
  * @private
  */
 function toFontString(font) {
index f40d8a8894b4242860d72db4bb1a7f1897a7fbee..2f8eadc7717b7eb6eda9138725d13fdd19faedfa 100644 (file)
@@ -63,7 +63,7 @@ function getSegment(segment, points, bounds) {
  * @param {number} segment.end - end index of the segment, referring the points array
  * @param {boolean} segment.loop - indicates that the segment is a loop
  * @param {Point[]} points - the points that this segment refers to
- * @param {object} bounds
+ * @param {object} [bounds]
  * @param {string} bounds.property - the property of a `Point` we are bounding. `x`, `y` or `angle`.
  * @param {number} bounds.start - start value of the property
  * @param {number} bounds.end - end value of the property
@@ -114,7 +114,7 @@ export function _boundSegment(segment, points, bounds) {
 /**
  * Returns the segments of the line that are inside given bounds
  * @param {Line} line
- * @param {object} bounds
+ * @param {object} [bounds]
  * @param {string} bounds.property - the property we are bounding with. `x`, `y` or `angle`.
  * @param {number} bounds.start - start value of the `property`
  * @param {number} bounds.end - end value of the `property`
index b1defabb6337c405abc097f2166c170ea1656089..801eecb4e20b17566b96210f498429237ba8fe80 100644 (file)
@@ -12,11 +12,8 @@ export default class BasePlatform {
         * the [W3C Canvas 2D Context API standard]{@link https://www.w3.org/TR/2dcontext/}.
         * @param {HTMLCanvasElement} canvas - The canvas from which to acquire context (platform specific)
         * @param {object} options - The chart options
-        * @returns {CanvasRenderingContext2D} context2d instance
         */
-       acquireContext(canvas, options) { // eslint-disable-line no-unused-vars
-               return undefined;
-       }
+       acquireContext(canvas, options) {} // eslint-disable-line no-unused-vars
 
        /**
         * Called at chart destruction time, releases any resources associated to the context
index 220aa74db61f0a4af95ba510d26f093d81c82b9c..df8c29cf466a14b3ebf371db10dd7f1ba737d4f8 100644 (file)
@@ -37,7 +37,7 @@ const EVENT_TYPES = {
  * `element` has a size relative to its parent and this last one is not yet displayed,
  * for example because of `display: none` on a parent node.
  * @see https://developer.mozilla.org/en-US/docs/Web/CSS/used_value
- * @returns {number} Size in pixels or undefined if unknown.
+ * @returns {number=} Size in pixels or undefined if unknown.
  */
 function readUsedSize(element, property) {
        const value = helpers.dom.getStyle(element, property);
@@ -307,7 +307,7 @@ export default class DomPlatform extends BasePlatform {
        /**
         * @param {HTMLCanvasElement} canvas
         * @param {{ options: { aspectRatio?: number; }; }} config
-        * @return {CanvasRenderingContext2D=}
+        * @return {CanvasRenderingContext2D|null}
         */
        acquireContext(canvas, config) {
                // To prevent canvas fingerprinting, some add-ons undefine the getContext
index e1854ff58d261eabf53c4d66fc35da995f163805..07d3f2ae37cba53162903b5adbe15c97240956c8 100644 (file)
@@ -2,7 +2,10 @@ import {isNullOrUndef, valueOrDefault} from '../helpers/helpers.core';
 import {almostEquals, almostWhole, log10, _decimalPlaces, _setMinAndMaxByKey, sign} from '../helpers/helpers.math';
 import Scale from '../core/core.scale';
 
-// Implementation of the nice number algorithm used in determining where axis labels will go
+/**
+ * Implementation of the nice number algorithm used in determining where axis labels will go
+ * @return {number}
+ */
 function niceNum(range, round) {
        const exponent = Math.floor(log10(range));
        const fraction = range / Math.pow(10, exponent);
index 367e5fcf3322218bafc7623728d0ccd544b510e8..9b9dc806e253675b465903f5a5b2be3b19c91c9f 100644 (file)
@@ -615,7 +615,7 @@ class TimeScale extends Scale {
         * @param {object} obj
         * @param {string} axis
         * @param {number} index
-        * @return {number}
+        * @return {number|null}
         * @private
         */
        _parseObject(obj, axis, index) {