Skip to content

Commit 2dc0902

Browse files
authored
🤖 Merge PR DefinitelyTyped#73657 feat(plotly.js): add jsdoc for MapboxLayers, fix a few attributes by @hkleungai
1 parent ca24558 commit 2dc0902

File tree

4 files changed

+374
-10
lines changed

4 files changed

+374
-10
lines changed

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

Lines changed: 113 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,42 @@ export interface LegendClickEvent {
156156
}
157157

158158
export interface MapboxCenter {
159+
/**
160+
* Sets the latitude of the center of the map (in degrees North).
161+
*/
159162
lon: number;
163+
/**
164+
* Sets the longitude of the center of the map (in degrees East).
165+
*/
160166
lat: number;
161167
}
162168

163169
export interface MapboxSymbol {
170+
/**
171+
* Sets the symbol icon image (mapbox.layer.layout.icon-image).
172+
* Full list: https://www.mapbox.com/maki-icons/
173+
*/
164174
icon: string;
175+
/**
176+
* Sets the symbol icon size (mapbox.layer.layout.icon-size).
177+
* Has an effect only when `type` is set to *symbol*.
178+
*/
165179
iconsize: number;
180+
/**
181+
* Sets the symbol text (mapbox.layer.layout.text-field).
182+
*/
166183
text: string;
184+
/**
185+
* Sets the symbol and/or text placement (mapbox.layer.layout.symbol-placement).
186+
* If `placement` is *point*, the label is placed where the geometry is located.
187+
* If `placement` is *line*, the label is placed along the line of the geometry.
188+
* If `placement` is *line-center*, the label is placed on the center of the geometry.
189+
*/
167190
placement: "point" | "line" | "line-center";
168191
textfont: Partial<Font>;
192+
/**
193+
* Sets the positions of the `text` elements with respects to the (x,y) coordinates.
194+
*/
169195
textposition:
170196
| "top left"
171197
| "top center"
@@ -176,23 +202,106 @@ export interface MapboxSymbol {
176202
| "bottom right";
177203
}
178204
export interface MapboxLayers {
179-
visible: true;
205+
/**
206+
* Determines whether this layer is displayed.
207+
*/
208+
visible: boolean;
209+
/**
210+
* Sets the source type for this layer, that is the type of the layer data.
211+
*/
180212
sourcetype: "geojson" | "vecotr" | "raster" | "image";
181-
source: number | string;
213+
/**
214+
* Sets the source data for this layer (mapbox.layer.source).
215+
* When `sourcetype` is set to *geojson*, `source` can be a URL to a GeoJSON or a GeoJSON object.
216+
* When `sourcetype` is set to *vector* or *raster*, `source` can be a URL or an array of tile URLs.
217+
* When `sourcetype` is set to *image*, `source` can be a URL to an image.
218+
*/
219+
source: any;
220+
/**
221+
* Specifies the layer to use from a vector tile source (mapbox.layer.source-layer).
222+
* Required for *vector* source type that supports multiple layers.
223+
*/
182224
sourcelayer: string;
225+
/**
226+
* Sets the attribution for this source.
227+
*/
183228
sourceattribution: string;
229+
/**
230+
* Sets the layer type,
231+
* that is the how the layer data set in `source` will be rendered With `sourcetype` set to *geojson*,
232+
* the following values are allowed: *circle*, *line*, *fill* and *symbol*.
233+
* But note that *line* and *fill* are not compatible with Point GeoJSON geometries.
234+
* With `sourcetype` set to *vector*, the following values are allowed: *circle*, *line*, *fill* and *symbol*.
235+
* With `sourcetype` set to *raster* or `*image*`, only the *raster* value is allowed.
236+
*/
184237
type: "circle" | "line" | "fill" | "symbol" | "raster";
238+
/**
239+
* Sets the coordinates array contains [longitude, latitude] pairs for the image corners listed in clockwise order: top left, top right, bottom right, bottom left.
240+
* Only has an effect for *image* `sourcetype`.
241+
*/
185242
coordinates: number | string;
243+
/**
244+
* Determines if the layer will be inserted before the layer with the specified ID.
245+
* If omitted or set to '', the layer will be inserted above every existing layer.
246+
*/
186247
below: string;
248+
/**
249+
* Sets the primary layer color.
250+
* If `type` is *circle*, color corresponds to the circle color (mapbox.layer.paint.circle-color).
251+
* If `type` is *line*, color corresponds to the line color (mapbox.layer.paint.line-color).
252+
* If `type` is *fill*, color corresponds to the fill color (mapbox.layer.paint.fill-color).
253+
* If `type` is *symbol*, color corresponds to the icon color (mapbox.layer.paint.icon-color).
254+
*/
187255
color: Color;
256+
/**
257+
* Sets the opacity of the layer.
258+
* If `type` is *circle*, opacity corresponds to the circle opacity (mapbox.layer.paint.circle-opacity).
259+
* If `type` is *line*, opacity corresponds to the line opacity (mapbox.layer.paint.line-opacity).
260+
* If `type` is *fill*, opacity corresponds to the fill opacity (mapbox.layer.paint.fill-opacity).
261+
* If `type` is *symbol*, opacity corresponds to the icon/text opacity (mapbox.layer.paint.text-opacity).
262+
*/
188263
opacity: number;
264+
/**
265+
* Sets the minimum zoom level (mapbox.layer.minzoom).
266+
* At zoom levels less than the minzoom, the layer will be hidden.
267+
*/
189268
minzoom: number;
269+
/**
270+
* Sets the maximum zoom level (mapbox.layer.maxzoom).
271+
* At zoom levels equal to or greater than the maxzoom, the layer will be hidden.
272+
*/
190273
maxzoom: number;
191-
circle: { radius: number };
274+
circle: {
275+
/**
276+
* Sets the circle radius (mapbox.layer.paint.circle-radius).
277+
* Has an effect only when `type` is set to *circle*.
278+
*/
279+
radius: number;
280+
};
192281
line: Partial<ShapeLine>;
193-
fill: { outlinecolor: Color };
282+
fill: {
283+
/**
284+
* Sets the fill outline color (mapbox.layer.paint.fill-outline-color).
285+
* Has an effect only when `type` is set to *fill*.
286+
*/
287+
outlinecolor: Color;
288+
};
194289
symbol: Partial<MapboxSymbol>;
290+
/**
291+
* When used in a template, named items are created in the output figure in addition to any items the figure already has in this array.
292+
* You can modify these items in the output figure by making your own item with `templateitemname` matching this `name`
293+
* alongside your modifications (including `visible: false` or `enabled: false` to hide it).
294+
* Has no effect outside of a template.
295+
*/
195296
name: string;
297+
/**
298+
* Used to refer to a named item in this array in the template.
299+
* Named items from the template will be created even without a matching item in the input figure,
300+
* but you can modify one by making an item with `templateitemname` matching its `name`,
301+
* alongside your modifications (including `visible: false` or `enabled: false` to hide it).
302+
* If there is no template or no matching item,
303+
* this item will be hidden unless you explicitly show it with `visible: true`.
304+
*/
196305
templateitemname: string;
197306
}
198307

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

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,80 @@ function rand() {
12411241
bearing: 30,
12421242
bounds: { east: 0, west: 0, south: 0, north: 0 },
12431243
pitch: 0,
1244-
layers: [],
1244+
layers: [
1245+
{
1246+
// Circle layer
1247+
visible: true,
1248+
sourcetype: "geojson",
1249+
source: {
1250+
type: "Feature",
1251+
properties: {},
1252+
geometry: {
1253+
type: "Point",
1254+
coordinates: [-74.0060, 40.7128],
1255+
},
1256+
},
1257+
type: "circle",
1258+
circle: { radius: 10 },
1259+
color: "rgb(255, 0, 0)",
1260+
opacity: 0.8,
1261+
minzoom: 8,
1262+
maxzoom: 15,
1263+
},
1264+
{
1265+
// Line layer
1266+
visible: true,
1267+
sourcetype: "geojson",
1268+
source: {
1269+
type: "Feature",
1270+
geometry: {
1271+
type: "LineString",
1272+
coordinates: [
1273+
[-74.0060, 40.7128],
1274+
[-73.9857, 40.7484],
1275+
],
1276+
},
1277+
},
1278+
type: "line",
1279+
line: {
1280+
color: "#00ff00",
1281+
width: 2,
1282+
dash: "dashdot",
1283+
},
1284+
opacity: 0.6,
1285+
},
1286+
{
1287+
// Symbol layer
1288+
visible: true,
1289+
sourcetype: "geojson",
1290+
source: {
1291+
type: "Feature",
1292+
geometry: {
1293+
type: "Point",
1294+
coordinates: [-73.9857, 40.7484],
1295+
},
1296+
},
1297+
type: "symbol",
1298+
symbol: {
1299+
icon: "monument",
1300+
iconsize: 1.5,
1301+
text: "Empire State",
1302+
placement: "point",
1303+
textposition: "top center",
1304+
textfont: font,
1305+
},
1306+
},
1307+
{
1308+
// Raster layer
1309+
visible: true,
1310+
sourcetype: "raster",
1311+
source: "mapbox://mapbox.satellite",
1312+
type: "raster",
1313+
opacity: 0.7,
1314+
minzoom: 0,
1315+
maxzoom: 22,
1316+
},
1317+
],
12451318
uirevision: "uirevision",
12461319
},
12471320
margin: { r: 0, t: 0, b: 0, l: 0 },

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

Lines changed: 113 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,42 @@ export interface LegendClickEvent {
156156
}
157157

158158
export interface MapboxCenter {
159+
/**
160+
* Sets the latitude of the center of the map (in degrees North).
161+
*/
159162
lon: number;
163+
/**
164+
* Sets the longitude of the center of the map (in degrees East).
165+
*/
160166
lat: number;
161167
}
162168

163169
export interface MapboxSymbol {
170+
/**
171+
* Sets the symbol icon image (mapbox.layer.layout.icon-image).
172+
* Full list: https://www.mapbox.com/maki-icons/
173+
*/
164174
icon: string;
175+
/**
176+
* Sets the symbol icon size (mapbox.layer.layout.icon-size).
177+
* Has an effect only when `type` is set to *symbol*.
178+
*/
165179
iconsize: number;
180+
/**
181+
* Sets the symbol text (mapbox.layer.layout.text-field).
182+
*/
166183
text: string;
184+
/**
185+
* Sets the symbol and/or text placement (mapbox.layer.layout.symbol-placement).
186+
* If `placement` is *point*, the label is placed where the geometry is located.
187+
* If `placement` is *line*, the label is placed along the line of the geometry.
188+
* If `placement` is *line-center*, the label is placed on the center of the geometry.
189+
*/
167190
placement: "point" | "line" | "line-center";
168191
textfont: Partial<Font>;
192+
/**
193+
* Sets the positions of the `text` elements with respects to the (x,y) coordinates.
194+
*/
169195
textposition:
170196
| "top left"
171197
| "top center"
@@ -176,23 +202,106 @@ export interface MapboxSymbol {
176202
| "bottom right";
177203
}
178204
export interface MapboxLayers {
179-
visible: true;
205+
/**
206+
* Determines whether this layer is displayed.
207+
*/
208+
visible: boolean;
209+
/**
210+
* Sets the source type for this layer, that is the type of the layer data.
211+
*/
180212
sourcetype: "geojson" | "vecotr" | "raster" | "image";
181-
source: number | string;
213+
/**
214+
* Sets the source data for this layer (mapbox.layer.source).
215+
* When `sourcetype` is set to *geojson*, `source` can be a URL to a GeoJSON or a GeoJSON object.
216+
* When `sourcetype` is set to *vector* or *raster*, `source` can be a URL or an array of tile URLs.
217+
* When `sourcetype` is set to *image*, `source` can be a URL to an image.
218+
*/
219+
source: any;
220+
/**
221+
* Specifies the layer to use from a vector tile source (mapbox.layer.source-layer).
222+
* Required for *vector* source type that supports multiple layers.
223+
*/
182224
sourcelayer: string;
225+
/**
226+
* Sets the attribution for this source.
227+
*/
183228
sourceattribution: string;
229+
/**
230+
* Sets the layer type,
231+
* that is the how the layer data set in `source` will be rendered With `sourcetype` set to *geojson*,
232+
* the following values are allowed: *circle*, *line*, *fill* and *symbol*.
233+
* But note that *line* and *fill* are not compatible with Point GeoJSON geometries.
234+
* With `sourcetype` set to *vector*, the following values are allowed: *circle*, *line*, *fill* and *symbol*.
235+
* With `sourcetype` set to *raster* or `*image*`, only the *raster* value is allowed.
236+
*/
184237
type: "circle" | "line" | "fill" | "symbol" | "raster";
238+
/**
239+
* Sets the coordinates array contains [longitude, latitude] pairs for the image corners listed in clockwise order: top left, top right, bottom right, bottom left.
240+
* Only has an effect for *image* `sourcetype`.
241+
*/
185242
coordinates: number | string;
243+
/**
244+
* Determines if the layer will be inserted before the layer with the specified ID.
245+
* If omitted or set to '', the layer will be inserted above every existing layer.
246+
*/
186247
below: string;
248+
/**
249+
* Sets the primary layer color.
250+
* If `type` is *circle*, color corresponds to the circle color (mapbox.layer.paint.circle-color).
251+
* If `type` is *line*, color corresponds to the line color (mapbox.layer.paint.line-color).
252+
* If `type` is *fill*, color corresponds to the fill color (mapbox.layer.paint.fill-color).
253+
* If `type` is *symbol*, color corresponds to the icon color (mapbox.layer.paint.icon-color).
254+
*/
187255
color: Color;
256+
/**
257+
* Sets the opacity of the layer.
258+
* If `type` is *circle*, opacity corresponds to the circle opacity (mapbox.layer.paint.circle-opacity).
259+
* If `type` is *line*, opacity corresponds to the line opacity (mapbox.layer.paint.line-opacity).
260+
* If `type` is *fill*, opacity corresponds to the fill opacity (mapbox.layer.paint.fill-opacity).
261+
* If `type` is *symbol*, opacity corresponds to the icon/text opacity (mapbox.layer.paint.text-opacity).
262+
*/
188263
opacity: number;
264+
/**
265+
* Sets the minimum zoom level (mapbox.layer.minzoom).
266+
* At zoom levels less than the minzoom, the layer will be hidden.
267+
*/
189268
minzoom: number;
269+
/**
270+
* Sets the maximum zoom level (mapbox.layer.maxzoom).
271+
* At zoom levels equal to or greater than the maxzoom, the layer will be hidden.
272+
*/
190273
maxzoom: number;
191-
circle: { radius: number };
274+
circle: {
275+
/**
276+
* Sets the circle radius (mapbox.layer.paint.circle-radius).
277+
* Has an effect only when `type` is set to *circle*.
278+
*/
279+
radius: number;
280+
};
192281
line: Partial<ShapeLine>;
193-
fill: { outlinecolor: Color };
282+
fill: {
283+
/**
284+
* Sets the fill outline color (mapbox.layer.paint.fill-outline-color).
285+
* Has an effect only when `type` is set to *fill*.
286+
*/
287+
outlinecolor: Color;
288+
};
194289
symbol: Partial<MapboxSymbol>;
290+
/**
291+
* When used in a template, named items are created in the output figure in addition to any items the figure already has in this array.
292+
* You can modify these items in the output figure by making your own item with `templateitemname` matching this `name`
293+
* alongside your modifications (including `visible: false` or `enabled: false` to hide it).
294+
* Has no effect outside of a template.
295+
*/
195296
name: string;
297+
/**
298+
* Used to refer to a named item in this array in the template.
299+
* Named items from the template will be created even without a matching item in the input figure,
300+
* but you can modify one by making an item with `templateitemname` matching its `name`,
301+
* alongside your modifications (including `visible: false` or `enabled: false` to hide it).
302+
* If there is no template or no matching item,
303+
* this item will be hidden unless you explicitly show it with `visible: true`.
304+
*/
196305
templateitemname: string;
197306
}
198307

0 commit comments

Comments
 (0)