Skip to content

Commit

Permalink
Use lowercase for primitives in jsdocs (chartjs#6033)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann authored and jonrimmer committed Feb 14, 2019
1 parent 24c52e0 commit 896e545
Show file tree
Hide file tree
Showing 21 changed files with 222 additions and 214 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -9,6 +9,8 @@
/package-lock.json
.DS_Store
.idea
.project
.settings
.vscode
bower.json
*.log
Expand Down
10 changes: 5 additions & 5 deletions src/controllers/controller.bar.js
Expand Up @@ -190,8 +190,8 @@ module.exports = DatasetController.extend({

/**
* Returns the stacks based on groups and bar visibility.
* @param {Number} [last] - The dataset index
* @returns {Array} The stack list
* @param {number} [last] - The dataset index
* @returns {string[]} The list of stack IDs
* @private
*/
_getStacks: function(last) {
Expand Down Expand Up @@ -226,9 +226,9 @@ module.exports = DatasetController.extend({

/**
* Returns the stack index for the given dataset based on groups and bar visibility.
* @param {Number} [datasetIndex] - The dataset index
* @param {String} [name] - The stack name to find
* @returns {Number} The stack index
* @param {number} [datasetIndex] - The dataset index
* @param {string} [name] - The stack name to find
* @returns {number} The stack index
* @private
*/
getStackIndex: function(datasetIndex, name) {
Expand Down
1 change: 0 additions & 1 deletion src/controllers/controller.horizontalBar.js
@@ -1,4 +1,3 @@

'use strict';

var BarController = require('./controller.bar');
Expand Down
4 changes: 2 additions & 2 deletions src/core/core.animations.js
Expand Up @@ -20,8 +20,8 @@ module.exports = {
/**
* @param {Chart} chart - The chart to animate.
* @param {Chart.Animation} animation - The animation that we will animate.
* @param {Number} duration - The animation duration in ms.
* @param {Boolean} lazy - if true, the chart is not marked as animating to enable more responsive interactions
* @param {number} duration - The animation duration in ms.
* @param {boolean} lazy - if true, the chart is not marked as animating to enable more responsive interactions
*/
addAnimation: function(chart, animation, duration, lazy) {
var animations = this.animations;
Expand Down
8 changes: 5 additions & 3 deletions src/core/core.controller.js
Expand Up @@ -736,8 +736,10 @@ helpers.extend(Chart.prototype, /** @lends Chart */ {
plugins.notify(me, 'afterTooltipDraw', [args]);
},

// Get the single element that was clicked on
// @return : An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw
/**
* Get the single element that was clicked on
* @return An object containing the dataset index and element index of the matching element. Also contains the rectangle that was draw
*/
getElementAtEvent: function(e) {
return Interaction.modes.single(this, e);
},
Expand Down Expand Up @@ -970,7 +972,7 @@ helpers.extend(Chart.prototype, /** @lends Chart */ {
* Handle an event
* @private
* @param {IEvent} event the event to handle
* @return {Boolean} true if the chart needs to re-render
* @return {boolean} true if the chart needs to re-render
*/
handleEvent: function(e) {
var me = this;
Expand Down
22 changes: 12 additions & 10 deletions src/core/core.helpers.js
Expand Up @@ -123,8 +123,8 @@ module.exports = function() {
/**
* Returns the number of decimal places
* i.e. the number of digits after the decimal point, of the value of this Number.
* @param {Number} x - A number.
* @returns {Number} The number of decimal places.
* @param {number} x - A number.
* @returns {number} The number of decimal places.
*/
helpers.decimalPlaces = function(x) {
if (!helpers.isFinite(x)) {
Expand Down Expand Up @@ -173,9 +173,9 @@ module.exports = function() {
/**
* Returns the aligned pixel value to avoid anti-aliasing blur
* @param {Chart} chart - The chart instance.
* @param {Number} pixel - A pixel value.
* @param {Number} width - The width of the element.
* @returns {Number} The aligned pixel value.
* @param {number} pixel - A pixel value.
* @param {number} width - The width of the element.
* @returns {number} The aligned pixel value.
* @private
*/
helpers._alignPixel = function(chart, pixel, width) {
Expand Down Expand Up @@ -430,11 +430,13 @@ module.exports = function() {
return value !== undefined && value !== null && value !== 'none';
}

// Private helper to get a constraint dimension
// @param domNode : the node to check the constraint on
// @param maxStyle : the style that defines the maximum for the direction we are using (maxWidth / maxHeight)
// @param percentageProperty : property of parent to use when calculating width as a percentage
// @see https://www.nathanaeljones.com/blog/2013/reading-max-width-cross-browser
/**
* Returns the max width or height of the given DOM node in a cross-browser compatible fashion
* @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
* @see {@link https://www.nathanaeljones.com/blog/2013/reading-max-width-cross-browser}
*/
function getConstraintDimension(domNode, maxStyle, percentageProperty) {
var view = document.defaultView;
var parentNode = helpers._getParentNode(domNode);
Expand Down
55 changes: 27 additions & 28 deletions src/core/core.interaction.js
Expand Up @@ -6,7 +6,7 @@ var helpers = require('../helpers/index');
* Helper function to get relative position for an event
* @param {Event|IEvent} event - The event to get the position for
* @param {Chart} chart - The chart
* @returns {Point} the event position
* @returns {object} the event position
*/
function getRelativePosition(e, chart) {
if (e.native) {
Expand All @@ -21,8 +21,8 @@ function getRelativePosition(e, chart) {

/**
* Helper function to traverse all of the visible elements in the chart
* @param chart {chart} the chart
* @param handler {Function} the callback to execute for each visible item
* @param {Chart} chart - the chart
* @param {function} handler - the callback to execute for each visible item
*/
function parseVisibleItems(chart, handler) {
var datasets = chart.data.datasets;
Expand All @@ -45,8 +45,8 @@ function parseVisibleItems(chart, handler) {

/**
* Helper function to get the items that intersect the event position
* @param items {ChartElement[]} elements to filter
* @param position {Point} the point to be nearest to
* @param {ChartElement[]} items - elements to filter
* @param {object} position - the point to be nearest to
* @return {ChartElement[]} the nearest items
*/
function getIntersectItems(chart, position) {
Expand All @@ -63,10 +63,10 @@ function getIntersectItems(chart, position) {

/**
* Helper function to get the items nearest to the event position considering all visible items in teh chart
* @param chart {Chart} the chart to look at elements from
* @param position {Point} the point to be nearest to
* @param intersect {Boolean} if true, only consider items that intersect the position
* @param distanceMetric {Function} function to provide the distance between points
* @param {Chart} chart - the chart to look at elements from
* @param {object} position - the point to be nearest to
* @param {boolean} intersect - if true, only consider items that intersect the position
* @param {function} distanceMetric - function to provide the distance between points
* @return {ChartElement[]} the nearest items
*/
function getNearestItems(chart, position, intersect, distanceMetric) {
Expand All @@ -80,7 +80,6 @@ function getNearestItems(chart, position, intersect, distanceMetric) {

var center = element.getCenterPoint();
var distance = distanceMetric(position, center);

if (distance < minDistance) {
nearestItems = [element];
minDistance = distance;
Expand All @@ -96,7 +95,7 @@ function getNearestItems(chart, position, intersect, distanceMetric) {
/**
* Get a distance metric function for two points based on the
* axis mode setting
* @param {String} axis the axis mode. x|y|xy
* @param {string} axis - the axis mode. x|y|xy
*/
function getDistanceMetricForAxis(axis) {
var useX = axis.indexOf('x') !== -1;
Expand Down Expand Up @@ -179,9 +178,9 @@ module.exports = {
* If the options.intersect mode is false, we find the nearest item and return the items at the same index as that item
* @function Chart.Interaction.modes.index
* @since v2.4.0
* @param chart {chart} the chart we are returning items from
* @param e {Event} the event we are find things at
* @param options {IInteractionOptions} options to use during interaction
* @param {Chart} chart - the chart we are returning items from
* @param {Event} e - the event we are find things at
* @param {IInteractionOptions} options - options to use during interaction
* @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
*/
index: indexMode,
Expand All @@ -190,9 +189,9 @@ module.exports = {
* 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 {chart} the chart we are returning items from
* @param e {Event} the event we are find things at
* @param options {IInteractionOptions} options to use during interaction
* @param {Chart} chart - the chart we are returning items from
* @param {Event} e - the event we are find things at
* @param {IInteractionOptions} options - options to use during interaction
* @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
*/
dataset: function(chart, e, options) {
Expand Down Expand Up @@ -222,8 +221,8 @@ module.exports = {
* Point mode returns all elements that hit test based on the event position
* of the event
* @function Chart.Interaction.modes.intersect
* @param chart {chart} the chart we are returning items from
* @param e {Event} the event we are find things at
* @param {Chart} chart - the chart we are returning items from
* @param {Event} e - the event we are find things at
* @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
*/
point: function(chart, e) {
Expand All @@ -234,9 +233,9 @@ module.exports = {
/**
* nearest mode returns the element closest to the point
* @function Chart.Interaction.modes.intersect
* @param chart {chart} the chart we are returning items from
* @param e {Event} the event we are find things at
* @param options {IInteractionOptions} options to use
* @param {Chart} chart - the chart we are returning items from
* @param {Event} e - the event we are find things at
* @param {IInteractionOptions} options - options to use
* @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
*/
nearest: function(chart, e, options) {
Expand All @@ -249,9 +248,9 @@ module.exports = {
/**
* x mode returns the elements that hit-test at the current x coordinate
* @function Chart.Interaction.modes.x
* @param chart {chart} the chart we are returning items from
* @param e {Event} the event we are find things at
* @param options {IInteractionOptions} options to use
* @param {Chart} chart - the chart we are returning items from
* @param {Event} e - the event we are find things at
* @param {IInteractionOptions} options - options to use
* @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
*/
x: function(chart, e, options) {
Expand Down Expand Up @@ -280,9 +279,9 @@ module.exports = {
/**
* y mode returns the elements that hit-test at the current y coordinate
* @function Chart.Interaction.modes.y
* @param chart {chart} the chart we are returning items from
* @param e {Event} the event we are find things at
* @param options {IInteractionOptions} options to use
* @param {Chart} chart - the chart we are returning items from
* @param {Event} e - the event we are find things at
* @param {IInteractionOptions} options - options to use
* @return {Chart.Element[]} Array of elements that are under the point. If none are found, an empty array is returned
*/
y: function(chart, e, options) {
Expand Down
34 changes: 17 additions & 17 deletions src/core/core.layouts.js
Expand Up @@ -67,19 +67,19 @@ defaults._set('global', {

/**
* @interface ILayoutItem
* @prop {String} position - The position of the item in the chart layout. Possible values are
* @prop {string} position - The position of the item in the chart layout. Possible values are
* 'left', 'top', 'right', 'bottom', and 'chartArea'
* @prop {Number} weight - The weight used to sort the item. Higher weights are further away from the chart area
* @prop {Boolean} fullWidth - if true, and the item is horizontal, then push vertical boxes down
* @prop {Function} isHorizontal - returns true if the layout item is horizontal (ie. top or bottom)
* @prop {Function} update - Takes two parameters: width and height. Returns size of item
* @prop {Function} getPadding - Returns an object with padding on the edges
* @prop {Number} width - Width of item. Must be valid after update()
* @prop {Number} height - Height of item. Must be valid after update()
* @prop {Number} left - Left edge of the item. Set by layout system and cannot be used in update
* @prop {Number} top - Top edge of the item. Set by layout system and cannot be used in update
* @prop {Number} right - Right edge of the item. Set by layout system and cannot be used in update
* @prop {Number} bottom - Bottom edge of the item. Set by layout system and cannot be used in update
* @prop {number} weight - The weight used to sort the item. Higher weights are further away from the chart area
* @prop {boolean} fullWidth - if true, and the item is horizontal, then push vertical boxes down
* @prop {function} isHorizontal - returns true if the layout item is horizontal (ie. top or bottom)
* @prop {function} update - Takes two parameters: width and height. Returns size of item
* @prop {function} getPadding - Returns an object with padding on the edges
* @prop {number} width - Width of item. Must be valid after update()
* @prop {number} height - Height of item. Must be valid after update()
* @prop {number} left - Left edge of the item. Set by layout system and cannot be used in update
* @prop {number} top - Top edge of the item. Set by layout system and cannot be used in update
* @prop {number} right - Right edge of the item. Set by layout system and cannot be used in update
* @prop {number} bottom - Bottom edge of the item. Set by layout system and cannot be used in update
*/

// The layout service is very self explanatory. It's responsible for the layout within a chart.
Expand Down Expand Up @@ -110,7 +110,7 @@ module.exports = {
/**
* Remove a layoutItem from a chart
* @param {Chart} chart - the chart to remove the box from
* @param {Object} layoutItem - the item to remove from the layout
* @param {ILayoutItem} layoutItem - the item to remove from the layout
*/
removeBox: function(chart, layoutItem) {
var index = chart.boxes ? chart.boxes.indexOf(layoutItem) : -1;
Expand All @@ -122,8 +122,8 @@ module.exports = {
/**
* Sets (or updates) options on the given `item`.
* @param {Chart} chart - the chart in which the item lives (or will be added to)
* @param {Object} item - the item to configure with the given options
* @param {Object} options - the new item options.
* @param {ILayoutItem} item - the item to configure with the given options
* @param {object} options - the new item options.
*/
configure: function(chart, item, options) {
var props = ['fullWidth', 'position', 'weight'];
Expand All @@ -143,8 +143,8 @@ module.exports = {
* Fits boxes of the given chart into the given size by having each box measure itself
* then running a fitting algorithm
* @param {Chart} chart - the chart
* @param {Number} width - the width to fit into
* @param {Number} height - the height to fit into
* @param {number} width - the width to fit into
* @param {number} height - the height to fit into
*/
update: function(chart, width, height) {
if (!chart) {
Expand Down

0 comments on commit 896e545

Please sign in to comment.