Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rewrite canvas helpers to ts #11100

Merged
merged 3 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/core/core.scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const offsetFromEdge = (scale, edge, offset) => edge === 'top' || edge === 'left
const getTicksLimit = (ticksLength, maxTicksLimit) => Math.min(maxTicksLimit || ticksLength, ticksLength);

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

Expand Down Expand Up @@ -120,6 +120,7 @@ function createTickContext(parent, index, tick) {
}

function titleAlign(align, position, reverse) {
/** @type {CanvasTextAlign} */
let ret = _toLeftRightCenter(align);
if ((reverse && position !== 'right') || (!reverse && position === 'right')) {
ret = reverseAlign(ret);
Expand Down Expand Up @@ -839,7 +840,7 @@ export default class Scale extends Element {
} else if (isArray(label)) {
// if it is an array let's measure each element
for (j = 0, jlen = label.length; j < jlen; ++j) {
nestedLabel = label[j];
nestedLabel = /** @type {string} */ (label[j]);
// Undefined labels and arrays should not be measured
if (!isNullOrUndef(nestedLabel) && !isArray(nestedLabel)) {
width = _measureText(ctx, cache.data, cache.gc, width, nestedLabel);
Expand Down
3 changes: 3 additions & 0 deletions src/elements/element.line.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ function lineTo(ctx, previous, target) {
ctx.lineTo(target.x, target.y);
}

/**
* @returns {any}
LeeLenaleee marked this conversation as resolved.
Show resolved Hide resolved
*/
function getLineMethod(options) {
if (options.stepped) {
return _steppedLineTo;
Expand Down
Loading