JSDoc and other cleanup (#7057)

This commit is contained in:
Ben McCann
2020-02-05 05:27:02 -08:00
committed by GitHub
parent c79e8090e8
commit f9cd9fdf76
6 changed files with 40 additions and 41 deletions

View File

@@ -115,11 +115,11 @@ var positioners = {
/**
* Average mode places the tooltip at the average position of the elements shown
* @function Chart.Tooltip.positioners.average
* @param elements {ChartElement[]} the elements being displayed in the tooltip
* @param items {object[]} the items being displayed in the tooltip
* @returns {object} tooltip position
*/
average: function(elements) {
if (!elements.length) {
average: function(items) {
if (!items.length) {
return false;
}
@@ -128,8 +128,8 @@ var positioners = {
var y = 0;
var count = 0;
for (i = 0, len = elements.length; i < len; ++i) {
var el = elements[i].element;
for (i = 0, len = items.length; i < len; ++i) {
var el = items[i].element;
if (el && el.hasValue()) {
var pos = el.tooltipPosition();
x += pos.x;
@@ -147,18 +147,18 @@ var positioners = {
/**
* Gets the tooltip position nearest of the item nearest to the event position
* @function Chart.Tooltip.positioners.nearest
* @param elements {Chart.Element[]} the tooltip elements
* @param items {object[]} the tooltip items
* @param eventPosition {object} the position of the event in canvas coordinates
* @returns {object} the tooltip position
*/
nearest: function(elements, eventPosition) {
nearest: function(items, eventPosition) {
var x = eventPosition.x;
var y = eventPosition.y;
var minDistance = Number.POSITIVE_INFINITY;
var i, len, nearestElement;
for (i = 0, len = elements.length; i < len; ++i) {
var el = elements[i].element;
for (i = 0, len = items.length; i < len; ++i) {
var el = items[i].element;
if (el && el.hasValue()) {
var center = el.getCenterPoint();
var d = helpers.math.distanceBetweenPoints(eventPosition, center);
@@ -199,8 +199,8 @@ function pushOrConcat(base, toPush) {
/**
* Returns array of strings split by newline
* @param {string} str - The value to split by newline.
* @returns {string[]} value if newline present - Returned from String split() method
* @param {string|undefined} str - The value to split by newline.
* @returns {string|string[]} value if newline present - Returned from String split() method
* @function
*/
function splitNewlines(str) {