Skip to content

fix(types): add optional additionalAngle parameter to RadialLinearScale.getPointPosition - #12317

Open
marina-semeia wants to merge 1 commit into
chartjs:masterfrom
marina-semeia:fix/types-get-point-position-additional-angle
Open

marina-semeia wants to merge 1 commit into
chartjs:masterfrom
marina-semeia:fix/types-get-point-position-additional-angle

Conversation

@marina-semeia

@marina-semeia marina-semeia commented Sep 24, 2026 •

Copy link
Copy Markdown

The getPointPosition method of RadialLinearScale accepts a third, optional additionalAngle parameter in its implementation (src/scales/scale.radialLinear.js):

getPointPosition(index, distanceFromCenter, additionalAngle = 0) {
  const angle = this.getIndexAngle(index) - HALF_PI + additionalAngle;
  // ...
}

It is already used internally (e.g. for pointLabels.centerPointLabels), but it is missing from the TypeScript definitions, so passing it from user code fails:

const scale = chart.scales.r as RadialLinearScale;
scale.getPointPosition(0, 100, Math.PI / 10);
// TS error: Expected 2 arguments, but got 3.

This is useful when extending RadarController to position points between grid lines instead of on them.

Changes

  • Added the optional additionalAngle?: number parameter to RadialLinearScale.getPointPosition in src/types/index.d.ts.
  • Added a type test in test/types/scales/radial_point_position.ts (fails with TS2554 without the fix, passes with it).
import { Chart, RadialLinearScale } from "chart.js";

const chart = new Chart(document.createElement("canvas"), {
  type: "radar",
  data: { labels: ["A", "B"], datasets: [{ data: [10, 20] }] }
});

const scale = chart.scales.r as RadialLinearScale;
const { x, y, angle } = scale.getPointPosition(0, 100, Math.PI / 2); // OK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant