/**
* Handle an event
* @private
- * @param {IEvent} event the event to handle
+ * @param {IEvent} e the event to handle
* @return {boolean} true if the chart needs to re-render
*/
handleEvent(e) {
// Re-sync meta data in case the user replaced the data array or if we missed
// any updates and so make sure that we handle number of datapoints changing.
- me.resyncElements(dataChanged | labelsChanged | scaleChanged | stackChanged);
+ me.resyncElements(dataChanged || labelsChanged || scaleChanged || stackChanged);
// if stack changed, update stack values for the whole dataset
if (stackChanged) {
me._cacheScaleStackStatus();
},
- update: helpers.noop,
+ /**
+ * @param {string} mode
+ */
+ update: function(mode) {}, // eslint-disable-line no-unused-vars
draw: function() {
const ctx = this._ctx;
* Returns a set of predefined style properties that should be used to represent the dataset
* or the data if the index is specified
* @param {number} index - data index
+ * @param {boolean} [active] - true if hover
* @return {IStyleInterface} style object
*/
getStyle: function(index, active) {
/**
* Helper function to get relative position for an event
- * @param {Event|IEvent} event - The event to get the position for
+ * @param {Event|IEvent} e - The event to get the position for
* @param {Chart} chart - The chart
* @returns {object} the event position
*/
* @param {string} axis - the axis mide. x|y|xy
* @param {number} value - the value to find
* @param {boolean} intersect - should the element intersect
- * @returns {lo, hi} indices to search data array between
+ * @returns {{lo:number, hi:number}} indices to search data array between
*/
function binarySearch(metaset, axis, value, intersect) {
const {controller, data, _sorted} = metaset;
* @param {string} axis - the axis mode. x|y|xy
* @param {object} position - the point to be nearest to
* @param {function} handler - the callback to execute for each visible item
- * @param {boolean} intersect - consider intersecting items
+ * @param {boolean} [intersect] - consider intersecting items
*/
function optimizedEvaluateItems(chart, axis, position, handler, intersect) {
const metasets = chart._getSortedVisibleDatasetMetas();
* Helper function to get the items nearest to the event position considering all visible items in the chart
* @param {Chart} chart - the chart to look at elements from
* @param {object} position - the point to be nearest to
- * @param {function} axis - the axes along which to measure distance
- * @param {boolean} intersect - if true, only consider items that intersect the position
+ * @param {string} axis - the axes along which to measure distance
+ * @param {boolean} [intersect] - if true, only consider items that intersect the position
* @return {ChartElement[]} the nearest items
*/
function getNearestItems(chart, position, axis, intersect) {
* Get the padding needed for the scale
* @method getPadding
* @private
- * @returns {Padding} the necessary padding
+ * @returns {object} the necessary padding
*/
getPadding() {
const me = this;
beforeBuildTicks() {
call(this.options.beforeBuildTicks, [this]);
}
+ /**
+ * @return {object[]} the ticks
+ */
buildTicks() {}
afterBuildTicks() {
call(this.options.afterBuildTicks, [this]);
* Returns the location of the given data point. Value can either be an index or a numerical value
* The coordinate (0, 0) is at the upper-left corner of the canvas
* @param value
- * @param index
- * @param datasetIndex
*/
- getPixelForValue() {}
+ getPixelForValue(value) {} // eslint-disable-line no-unused-vars
/**
* Used to get the data value from a given pixel. This is the inverse of getPixelForValue
* The coordinate (0, 0) is at the upper-left corner of the canvas
* @param pixel
*/
- getValueForPixel() {}
+ getValueForPixel(pixel) {} // eslint-disable-line no-unused-vars
/**
* Returns the location of the tick at the given index
* @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
* @see {@link https://www.nathanaeljones.com/blog/2013/reading-max-width-cross-browser}
*/
function getConstraintDimension(domNode, maxStyle, percentageProperty) {
hasCNode ? parseMaxStyle(constrainedNode, domNode, percentageProperty) : infinity,
hasCContainer ? parseMaxStyle(constrainedContainer, parentNode, percentageProperty) : infinity);
}
-
- return 'none';
}
export function getStyle(el, property) {
document.defaultView.getComputedStyle(el, null).getPropertyValue(property);
}
-// returns Number or undefined if no constraint
+/** @return {number|undefined} number or undefined if no constraint */
function getConstraintWidth(domNode) {
return getConstraintDimension(domNode, 'max-width', 'clientWidth');
}
-// returns Number or undefined if no constraint
+/** @return {number|undefined} number or undefined if no constraint */
function getConstraintHeight(domNode) {
return getConstraintDimension(domNode, 'max-height', 'clientHeight');
}
* @param {object} options - The chart options
* @returns {CanvasRenderingContext2D} context2d instance
*/
- acquireContext() {}
+ acquireContext(canvas, options) {} // eslint-disable-line no-unused-vars
/**
* Called at chart destruction time, releases any resources associated to the context
* @param {CanvasRenderingContext2D} context - The context2d instance
* @returns {boolean} true if the method succeeded, else false
*/
- releaseContext() {}
+ releaseContext(context) {} // eslint-disable-line no-unused-vars
/**
* Registers the specified listener on the given chart.
* @param {function} listener - Receives a notification (an object that implements
* the {@link IEvent} interface) when an event of the specified type occurs.
*/
- addEventListener() {}
+ addEventListener(chart, type, listener) {} // eslint-disable-line no-unused-vars
/**
* Removes the specified listener previously registered with addEventListener.
* @param {string} type - The ({@link IEvent}) type to remove
* @param {function} listener - The listener function to remove from the event target.
*/
- removeEventListener() {}
+ removeEventListener(chart, type, listener) {} // eslint-disable-line no-unused-vars
/**
* @returns {number} the current devicePixelRatio of the device this platform is connected to.
// @todo if (fill[0] === '#')
function decodeFill(line, index, count) {
const fill = parseFillOption(line);
- let target = parseFloat(fill, 10);
+ let target = parseFloat(fill);
if (isFinite(target) && Math.floor(target) === target) {
if (fill[0] === '-' || fill[0] === '+') {
/**
* Helper function to get the box width based on the usePointStyle option
- * @param {object} labelopts - the label options on the legend
+ * @param {object} labelOpts - the label options on the legend
* @param {number} fontSize - the label font size
* @return {number} width of the color box area
*/
/**
* Handle an event
+ * @param {IEvent} e - The event to handle
* @private
- * @param {IEvent} event - The event to handle
*/
handleEvent(e) {
var me = this;
/**
* Returns array of strings split by newline
- * @param {string} value - The value to split by newline.
+ * @param {string} str - The value to split by newline.
* @returns {string[]} value if newline present - Returned from String split() method
* @function
*/
/**
* Handle an event
* @private
- * @param {IEvent} event - The event to handle
+ * @param {IEvent} e - The event to handle
* @returns {boolean} true if the tooltip changed
*/
handleEvent(e) {
* Generate a set of linear ticks
* @param generationOptions the options used to generate the ticks
* @param dataRange the range of the data
- * @returns {number[]} array of tick values
+ * @returns {object[]} array of tick objects
*/
function generateTicks(generationOptions, dataRange) {
const ticks = [];
* Generate a set of logarithmic ticks
* @param generationOptions the options used to generate the ticks
* @param dataRange the range of the data
- * @returns {number[]} array of tick values
+ * @returns {object[]} array of tick objects
*/
function generateTicks(generationOptions, dataRange) {
const endExp = Math.floor(log10(dataRange.max));
/**
* Return subset of `timestamps` between `min` and `max`.
* Timestamps are assumend to be in sorted order.
- * @param {int[]} timestamps - array of timestamps
- * @param {int} min - min value (timestamp)
- * @param {int} max - max value (timestamp)
+ * @param {number[]} timestamps - array of timestamps
+ * @param {number} min - min value (timestamp)
+ * @param {number} max - max value (timestamp)
*/
function filterBetween(timestamps, min, max) {
let start = 0;