mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[d3-shape] padAngle for arcs is optional (#23294)
This commit is contained in:
parent
df1b55d514
commit
d6cddb2fb3
@ -17,6 +17,7 @@ import { HierarchyPointLink, HierarchyPointNode } from 'd3-hierarchy';
|
||||
|
||||
let context: CanvasRenderingContext2D | null = document.querySelector('canvas')!.getContext('2d');
|
||||
let num: number;
|
||||
let padAngleMaybe: number | undefined;
|
||||
let pathStringMaybe: string | null;
|
||||
|
||||
// -----------------------------------------------------------------------------------
|
||||
@ -28,7 +29,7 @@ interface ArcDatum {
|
||||
oRadius: number;
|
||||
sAngle: number;
|
||||
eAngle: number;
|
||||
pAngle: number;
|
||||
pAngle?: number;
|
||||
}
|
||||
|
||||
const arcDefaultDatum: d3Shape.DefaultArcObject = {
|
||||
@ -39,6 +40,13 @@ const arcDefaultDatum: d3Shape.DefaultArcObject = {
|
||||
padAngle: 0.03
|
||||
};
|
||||
|
||||
const arcReducedDefaultDatum: d3Shape.DefaultArcObject = {
|
||||
innerRadius: 40,
|
||||
outerRadius: 60,
|
||||
startAngle: 0,
|
||||
endAngle: Math.PI / 2
|
||||
};
|
||||
|
||||
const arcDatum: ArcDatum = {
|
||||
iRadius: 40,
|
||||
oRadius: 60,
|
||||
@ -48,6 +56,7 @@ const arcDatum: ArcDatum = {
|
||||
};
|
||||
|
||||
let accessorArcDatumNumber: (this: any, d: ArcDatum, ...args: any[]) => number;
|
||||
let accessorArcDatumNumberOrUndefined: (this: any, d: ArcDatum, ...args: any[]) => number | undefined;
|
||||
let accessorArcDatumNumberOrNull: ((this: any, d: ArcDatum, ...args: any[]) => number) | null;
|
||||
|
||||
// DefaultArcObject interface ========================================================
|
||||
@ -64,7 +73,7 @@ num = defaultArcObject.innerRadius;
|
||||
num = defaultArcObject.outerRadius;
|
||||
num = defaultArcObject.startAngle;
|
||||
num = defaultArcObject.endAngle;
|
||||
num = defaultArcObject.padAngle;
|
||||
padAngleMaybe = defaultArcObject.padAngle;
|
||||
|
||||
// arc(...) create Arc generator =====================================================
|
||||
|
||||
@ -134,7 +143,7 @@ canvasArc = canvasArc.padAngle(0);
|
||||
svgArc = svgArc.padAngle(d => {
|
||||
return d.pAngle; // datum type is ArcDatum
|
||||
});
|
||||
accessorArcDatumNumber = svgArc.padAngle();
|
||||
accessorArcDatumNumberOrUndefined = svgArc.padAngle();
|
||||
|
||||
// padRadius(...) ----------------------------------------------------------------------
|
||||
|
||||
|
||||
10
types/d3-shape/index.d.ts
vendored
10
types/d3-shape/index.d.ts
vendored
@ -32,9 +32,9 @@ export interface DefaultArcObject {
|
||||
*/
|
||||
endAngle: number;
|
||||
/**
|
||||
* Pad angle of arcin radians.
|
||||
* Optional. Pad angle of arcin radians.
|
||||
*/
|
||||
padAngle: number;
|
||||
padAngle?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -230,7 +230,7 @@ export interface Arc<This, Datum> {
|
||||
* Returns the current pad angle accessor, which defaults to a function returning the padAngle property
|
||||
* of the first argument passed into it, or false if no data are passed in or the property is not defined.
|
||||
*/
|
||||
padAngle(): (this: This, d: Datum, ...args: any[]) => number;
|
||||
padAngle(): (this: This, d: Datum, ...args: any[]) => number | undefined;
|
||||
/**
|
||||
* Sets the pad angle to the specified number and returns this arc generator.
|
||||
*
|
||||
@ -248,7 +248,7 @@ export interface Arc<This, Datum> {
|
||||
*
|
||||
* @param angle Constant angle in radians.
|
||||
*/
|
||||
padAngle(angle: number): this;
|
||||
padAngle(angle: number | undefined): this;
|
||||
/**
|
||||
* Sets the pad angle to the specified function and returns this arc generator.
|
||||
*
|
||||
@ -267,7 +267,7 @@ export interface Arc<This, Datum> {
|
||||
* @param angle An accessor function returning a number in radians to be used as an angle. The accessor function is invoked in the same "this" context as the generator was invoked in and
|
||||
* receives the same arguments that were passed into the arc generator.
|
||||
*/
|
||||
padAngle(angle: (this: This, d: Datum, ...args: any[]) => number): this;
|
||||
padAngle(angle: (this: This, d: Datum, ...args: any[]) => number | undefined): this;
|
||||
|
||||
/**
|
||||
* Returns the current pad radius accessor, which defaults to null, indicating that the pad radius should be automatically computed as sqrt(innerRadius * innerRadius + outerRadius * outerRadius).
|
||||
|
||||
Loading…
Reference in New Issue
Block a user