Skip to content

Commit 1324672

Browse files
authored
refactor: rewrite canvas helpers to ts (#11100)
* refactor: rewrite canvas helpers to ts * refactor: review fixes * refactor: rm src/helpers/types.ts temporary entry point
1 parent 22c6906 commit 1324672

File tree

12 files changed

+374
-362
lines changed

12 files changed

+374
-362
lines changed

src/core/core.scale.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const offsetFromEdge = (scale, edge, offset) => edge === 'top' || edge === 'left
1111
const getTicksLimit = (ticksLength, maxTicksLimit) => Math.min(maxTicksLimit || ticksLength, ticksLength);
1212

1313
/**
14-
* @typedef { import('./core.controller.js').default } Chart
14+
* @typedef { import('../types/index.js').Chart } Chart
1515
* @typedef {{value:number | string, label?:string, major?:boolean, $context?:any}} Tick
1616
*/
1717

@@ -120,6 +120,7 @@ function createTickContext(parent, index, tick) {
120120
}
121121

122122
function titleAlign(align, position, reverse) {
123+
/** @type {CanvasTextAlign} */
123124
let ret = _toLeftRightCenter(align);
124125
if ((reverse && position !== 'right') || (!reverse && position === 'right')) {
125126
ret = reverseAlign(ret);
@@ -839,7 +840,7 @@ export default class Scale extends Element {
839840
} else if (isArray(label)) {
840841
// if it is an array let's measure each element
841842
for (j = 0, jlen = label.length; j < jlen; ++j) {
842-
nestedLabel = label[j];
843+
nestedLabel = /** @type {string} */ (label[j]);
843844
// Undefined labels and arrays should not be measured
844845
if (!isNullOrUndef(nestedLabel) && !isArray(nestedLabel)) {
845846
width = _measureText(ctx, cache.data, cache.gc, width, nestedLabel);

src/elements/element.line.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ function lineTo(ctx, previous, target) {
2222
ctx.lineTo(target.x, target.y);
2323
}
2424

25+
/**
26+
* @returns {any}
27+
*/
2528
function getLineMethod(options) {
2629
if (options.stepped) {
2730
return _steppedLineTo;

0 commit comments

Comments
 (0)