MCPcopy
hub / github.com/chartjs/Chart.js / PointElement

Class PointElement

src/elements/element.point.ts:20–107  ·  src/elements/element.point.ts::PointElement

Source from the content-addressed store, hash-verified

18export type PointProps = Point
19
20export default class PointElement extends Element<PointProps, PointOptions & PointHoverOptions> {
21
22 static id = class="st">'point';
23
24 parsed: CartesianParsedData;
25 skip?: boolean;
26 stop?: boolean;
27
28 /**
29 * @type {any}
30 */
31 static defaults = {
32 borderWidth: 1,
33 hitRadius: 1,
34 hoverBorderWidth: 1,
35 hoverRadius: 4,
36 pointStyle: class="st">'circle',
37 radius: 3,
38 rotation: 0
39 };
40
41 /**
42 * @type {any}
43 */
44 static defaultRoutes = {
45 backgroundColor: class="st">'backgroundColor',
46 borderColor: class="st">'borderColor'
47 };
48
49 constructor(cfg) {
50 super();
51
52 this.options = undefined;
53 this.parsed = undefined;
54 this.skip = undefined;
55 this.stop = undefined;
56
57 if (cfg) {
58 Object.assign(this, cfg);
59 }
60 }
61
62 inRange(mouseX: number, mouseY: number, useFinalPosition?: boolean) {
63 const options = this.options;
64 const {x, y} = this.getProps([class="st">'x', class="st">'y'], useFinalPosition);
65 return ((Math.pow(mouseX - x, 2) + Math.pow(mouseY - y, 2)) < Math.pow(options.hitRadius + options.radius, 2));
66 }
67
68 inXRange(mouseX: number, useFinalPosition?: boolean) {
69 return inRange(this, mouseX, class="st">'x', useFinalPosition);
70 }
71
72 inYRange(mouseY: number, useFinalPosition?: boolean) {
73 return inRange(this, mouseY, class="st">'y', useFinalPosition);
74 }
75
76 getCenterPoint(useFinalPosition?: boolean) {
77 const {x, y} = this.getProps([class="st">'x', class="st">'y'], useFinalPosition);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected