Skip to content

Commit 61bebf7

Browse files
authored
🤖 Merge PR DefinitelyTyped#74440 fix(plotly.js): update fgopacity & shape in Pattern, add array type by @hkleungai
1 parent 8407669 commit 61bebf7

File tree

4 files changed

+65
-20
lines changed

4 files changed

+65
-20
lines changed

‎types/plotly.js/index.d.ts‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ export interface Axis {
865865
autorange: true | false | "reversed" | "min reversed" | "max reversed" | "min" | "max";
866866
autorangeoptions: Partial<AutoRangeOptions>;
867867
/**
868-
* 'If *normal*, the range is computed in relation to the extrema
868+
* If *normal*, the range is computed in relation to the extrema
869869
* of the input data.
870870
* If *tozero*`, the range extends to 0,
871871
* regardless of the input data
@@ -970,7 +970,7 @@ export interface Axis {
970970
*/
971971
minexponent: number;
972972
/**
973-
* 'If `true`, even 4-digit integers are separated
973+
* If `true`, even 4-digit integers are separated
974974
*/
975975
separatethousands: boolean;
976976
/**
@@ -3155,51 +3155,59 @@ export interface CurrentValue {
31553155
font: Partial<Font>;
31563156
}
31573157

3158+
export type PatternShape = "" | "/" | "\\" | "x" | "-" | "|" | "+" | ".";
3159+
31583160
/**
3159-
* 'Sets the pattern within the marker.
3161+
* Sets the pattern within the marker.
31603162
*/
31613163
export interface Pattern {
31623164
/**
31633165
* Sets the shape of the pattern fill.
31643166
* By default, no pattern is used for filling the area.
31653167
*/
3166-
shape?: "" | "/" | "\\" | "x" | "-" | "|" | "+" | ".";
3168+
shape?: PatternShape | PatternShape[] | undefined;
3169+
/**
3170+
* Sets a custom path for pattern fill.
3171+
* Use with no `shape` or `solidity`, provide an SVG path string for
3172+
* the regions of the square from (0,0) to (`size`,`size`) to color.
3173+
*/
3174+
path?: string | undefined;
31673175
/**
31683176
* Determines whether `marker.color` should be used
31693177
* as a default to `bgcolor` or a `fgcolor`.
31703178
*/
3171-
fillmode?: "replace" | "overlay";
3179+
fillmode?: "replace" | "overlay" | undefined;
31723180
/**
31733181
* When there is no colorscale sets the color of background pattern fill.
31743182
* Defaults to a `marker.color` background when `fillmode` is *overlay*.
31753183
* Otherwise, defaults to a transparent background.
31763184
*/
3177-
bgcolor?: string;
3185+
bgcolor?: string | string[] | undefined;
31783186
/**
31793187
* When there is no colorscale sets the color of foreground pattern fill.
31803188
* Defaults to a `marker.color` background when `fillmode` is *replace*.
31813189
* Otherwise, defaults to dark grey or white
31823190
* to increase contrast with the `bgcolor`.
31833191
*/
3184-
fgcolor?: string;
3192+
fgcolor?: string | string[] | undefined;
31853193
/**
31863194
* Sets the opacity of the foreground pattern fill.
31873195
* Defaults to a 0.5 when `fillmode` is *overlay*.
31883196
* Otherwise, defaults to 1.
31893197
*/
3190-
fgopacity?: string;
3198+
fgopacity?: number | undefined;
31913199
/**
31923200
* Sets the size of unit squares of the pattern fill in pixels,
31933201
* which corresponds to the interval of repetition of the pattern.
31943202
*/
3195-
size?: number;
3203+
size?: number | number[] | undefined;
31963204
/**
31973205
* Sets the solidity of the pattern fill.
31983206
* Solidity is roughly the fraction of the area filled by the pattern.
31993207
* Solidity of 0 shows only the background color without pattern
32003208
* and solidty of 1 shows only the foreground color without pattern.
32013209
*/
3202-
solidity?: number;
3210+
solidity?: number | number[] | undefined;
32033211
}
32043212

32053213
export interface UpdateMenuButton {

‎types/plotly.js/test/core-tests.ts‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,12 +531,36 @@ const layout = {
531531
y: [0.45803057, 0.51208141, 0.29845217, 0.09788102, 0.2866858],
532532
type: "scatter",
533533
yaxis: "y",
534+
fill: "none",
535+
fillcolor: "#000000",
536+
fillpattern: {
537+
shape: ["+", "-"],
538+
path: "",
539+
fillmode: "replace",
540+
bgcolor: ["#ffffff"],
541+
fgcolor: ["#ff0000"],
542+
fgopacity: 0.5,
543+
size: 1,
544+
solidity: [0, 0.5],
545+
},
534546
},
535547
{
536548
x: [1, 2, 3, 4, 5],
537549
y: [150.36977661, 641.21444452, 39.2096064, 546.90053751, 97.10039431],
538550
type: "scatter",
539551
yaxis: "y2",
552+
fill: "none",
553+
fillcolor: "#000000",
554+
fillpattern: {
555+
shape: ["+", "-"],
556+
path: "",
557+
fillmode: "replace",
558+
bgcolor: ["#ffffff"],
559+
fgcolor: ["#ff0000"],
560+
fgopacity: 0.5,
561+
size: 1,
562+
solidity: [0, 0.5],
563+
},
540564
},
541565
];
542566
const layout: Partial<Layout> = {

‎types/plotly.js/v2/index.d.ts‎

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ export interface Axis {
867867
autorange: true | false | "reversed" | "min reversed" | "max reversed" | "min" | "max";
868868
autorangeoptions: Partial<AutoRangeOptions>;
869869
/**
870-
* 'If *normal*, the range is computed in relation to the extrema
870+
* If *normal*, the range is computed in relation to the extrema
871871
* of the input data.
872872
* If *tozero*`, the range extends to 0,
873873
* regardless of the input data
@@ -972,7 +972,7 @@ export interface Axis {
972972
*/
973973
minexponent: number;
974974
/**
975-
* 'If `true`, even 4-digit integers are separated
975+
* If `true`, even 4-digit integers are separated
976976
*/
977977
separatethousands: boolean;
978978
/**
@@ -3204,51 +3204,53 @@ export interface CurrentValue {
32043204
font: Partial<Font>;
32053205
}
32063206

3207+
export type PatternShape = "" | "/" | "\\" | "x" | "-" | "|" | "+" | ".";
3208+
32073209
/**
3208-
* 'Sets the pattern within the marker.
3210+
* Sets the pattern within the marker.
32093211
*/
32103212
export interface Pattern {
32113213
/**
32123214
* Sets the shape of the pattern fill.
32133215
* By default, no pattern is used for filling the area.
32143216
*/
3215-
shape?: "" | "/" | "\\" | "x" | "-" | "|" | "+" | ".";
3217+
shape?: PatternShape | PatternShape[] | undefined;
32163218
/**
32173219
* Determines whether `marker.color` should be used
32183220
* as a default to `bgcolor` or a `fgcolor`.
32193221
*/
3220-
fillmode?: "replace" | "overlay";
3222+
fillmode?: "replace" | "overlay" | undefined;
32213223
/**
32223224
* When there is no colorscale sets the color of background pattern fill.
32233225
* Defaults to a `marker.color` background when `fillmode` is *overlay*.
32243226
* Otherwise, defaults to a transparent background.
32253227
*/
3226-
bgcolor?: string;
3228+
bgcolor?: string | string[] | undefined;
32273229
/**
32283230
* When there is no colorscale sets the color of foreground pattern fill.
32293231
* Defaults to a `marker.color` background when `fillmode` is *replace*.
32303232
* Otherwise, defaults to dark grey or white
32313233
* to increase contrast with the `bgcolor`.
32323234
*/
3233-
fgcolor?: string;
3235+
fgcolor?: string | string[] | undefined;
32343236
/**
32353237
* Sets the opacity of the foreground pattern fill.
32363238
* Defaults to a 0.5 when `fillmode` is *overlay*.
32373239
* Otherwise, defaults to 1.
32383240
*/
3239-
fgopacity?: string;
3241+
fgopacity?: number | undefined;
32403242
/**
32413243
* Sets the size of unit squares of the pattern fill in pixels,
32423244
* which corresponds to the interval of repetition of the pattern.
32433245
*/
3244-
size?: number;
3246+
size?: number | number[] | undefined;
32453247
/**
32463248
* Sets the solidity of the pattern fill.
32473249
* Solidity is roughly the fraction of the area filled by the pattern.
32483250
* Solidity of 0 shows only the background color without pattern
32493251
* and solidty of 1 shows only the foreground color without pattern.
32503252
*/
3251-
solidity?: number;
3253+
solidity?: number | number[] | undefined;
32523254
}
32533255

32543256
export interface UpdateMenuButton {

‎types/plotly.js/v2/test/core-tests.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,17 @@ const layout = {
504504
labels: ["Eve", "Cain", "Seth", "Enos", "Noam", "Abel", "Awan", "Enoch", "Azura"],
505505
parents: ["", "Eve", "Eve", "Seth", "Seth", "Eve", "Eve", "Awan", "Eve"],
506506
maxdepth: 1,
507+
fill: "none",
508+
fillcolor: "#000000",
509+
fillpattern: {
510+
shape: ["+", "-"],
511+
fillmode: "replace",
512+
bgcolor: ["#ffffff"],
513+
fgcolor: ["#ff0000"],
514+
fgopacity: 0.5,
515+
size: 1,
516+
solidity: [0, 0.5],
517+
},
507518
},
508519
];
509520

0 commit comments

Comments
 (0)