Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions types/plotly.js/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ export interface Layout {
"yaxis.title": Partial<DataTitle>;
ternary: {}; // TODO
geo: {}; // TODO
map: Partial<Mapbox>;
mapbox: Partial<Mapbox>;
subplot: string;
radialaxis: Partial<Axis>;
Expand Down Expand Up @@ -1275,8 +1276,11 @@ export type ModeBarDefaultButtons =
| "toImage"
| "resetViews"
| "toggleSpikelines"
| "zoomInMap"
| "zoomInMapbox"
| "zoomOutMap"
| "zoomOutMapbox"
| "resetViewMap"
| "resetViewMapbox"
| "togglespikelines"
| "togglehover"
Expand Down Expand Up @@ -1448,10 +1452,12 @@ export type PlotType =
| "candlestick"
| "carpet"
| "choropleth"
| "choroplethmap"
| "choroplethmapbox"
| "cone"
| "contour"
| "contourcarpet"
| "densitymap"
| "densitymapbox"
| "funnel"
| "funnelarea"
Expand All @@ -1473,6 +1479,7 @@ export type PlotType =
| "scattercarpet"
| "scattergeo"
| "scattergl"
| "scattermap"
| "scattermapbox"
| "scatterpolar"
| "scatterpolargl"
Expand Down
4 changes: 4 additions & 0 deletions types/plotly.js/lib/choroplethmap.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const moduleType: "trace";
export const name: "choroplethmap";
export const categories: string[];
export const meta: { description: string };
4 changes: 4 additions & 0 deletions types/plotly.js/lib/densitymap.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const moduleType: "trace";
export const name: "densitymap";
export const categories: string[];
export const meta: { description: string };
4 changes: 4 additions & 0 deletions types/plotly.js/lib/scattermap.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const moduleType: "trace";
export const name: "scattermap";
export const categories: string[];
export const meta: { description: string };
106 changes: 106 additions & 0 deletions types/plotly.js/test/index-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,112 @@ function rand() {
Plotly.newPlot("myDiv", data, layout);
})();

//////////////////////////////////////////////////////////////////////
// Map plot
(() => {
const data: Array<Partial<PlotData>> = [
{
type: "scattermap",
text: ["A", "B", "C"],
lon: [0, 1, 2],
lat: [0, 1, 2],
marker: { color: "fuchsia", size: 4 },
},
];

const layout: Partial<Layout> = {
dragmode: "zoom",
map: {
accesstoken: "accesstoken",
domain: { x: [0], y: [0], row: 0, column: 0 },
style: "open-street-map",
center: { lat: 0, lon: -0 },
zoom: 3,
bearing: 30,
bounds: { east: 0, west: 0, south: 0, north: 0 },
pitch: 0,
layers: [
{
// Circle layer
visible: true,
sourcetype: "geojson",
source: {
type: "Feature",
properties: {},
geometry: {
type: "Point",
coordinates: [-74.0060, 40.7128],
},
},
type: "circle",
circle: { radius: 10 },
color: "rgb(255, 0, 0)",
opacity: 0.8,
minzoom: 8,
maxzoom: 15,
},
{
// Line layer
visible: true,
sourcetype: "geojson",
source: {
type: "Feature",
geometry: {
type: "LineString",
coordinates: [
[-74.0060, 40.7128],
[-73.9857, 40.7484],
],
},
},
type: "line",
line: {
color: "#00ff00",
width: 2,
dash: "dashdot",
},
opacity: 0.6,
},
{
// Symbol layer
visible: true,
sourcetype: "geojson",
source: {
type: "Feature",
geometry: {
type: "Point",
coordinates: [-73.9857, 40.7484],
},
},
type: "symbol",
symbol: {
icon: "monument",
iconsize: 1.5,
text: "Empire State",
placement: "point",
textposition: "top center",
textfont: font,
},
},
{
// Raster layer
visible: true,
sourcetype: "raster",
source: "mapbox://mapbox.satellite",
type: "raster",
opacity: 0.7,
minzoom: 0,
maxzoom: 22,
},
],
uirevision: "uirevision",
},
margin: { r: 0, t: 0, b: 0, l: 0 },
};

Plotly.newPlot("myDiv", data, layout);
})();

//////////////////////////////////////////////////////////////////////
// Plotly.animate as per https://plot.ly/javascript/animations/
(() => {
Expand Down
6 changes: 6 additions & 0 deletions types/plotly.js/test/register-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import calendars from "plotly.js/lib/calendars";
import candlestick from "plotly.js/lib/candlestick";
import carpet from "plotly.js/lib/carpet";
import choropleth from "plotly.js/lib/choropleth";
import choroplethmap from "plotly.js/lib/choroplethmap";
import choroplethmapbox from "plotly.js/lib/choroplethmapbox";
import cone from "plotly.js/lib/cone";
import contour from "plotly.js/lib/contour";
import contourcarpet from "plotly.js/lib/contourcarpet";
import Plotly from "plotly.js/lib/core";
import densitymap from "plotly.js/lib/densitymap";
import densitymapbox from "plotly.js/lib/densitymapbox";
import funnel from "plotly.js/lib/funnel";
import funnelarea from "plotly.js/lib/funnelarea";
Expand All @@ -32,6 +34,7 @@ import scatter3d from "plotly.js/lib/scatter3d";
import scattercarpet from "plotly.js/lib/scattercarpet";
import scattergeo from "plotly.js/lib/scattergeo";
import scattergl from "plotly.js/lib/scattergl";
import scattermap from "plotly.js/lib/scattermap";
import scattermapbox from "plotly.js/lib/scattermapbox";
import scatterpolar from "plotly.js/lib/scatterpolar";
import scatterpolargl from "plotly.js/lib/scatterpolargl";
Expand All @@ -55,10 +58,12 @@ Plotly.register([
candlestick,
carpet,
choropleth,
choroplethmap,
choroplethmapbox,
cone,
contour,
contourcarpet,
densitymap,
densitymapbox,
funnel,
funnelarea,
Expand All @@ -81,6 +86,7 @@ Plotly.register([
scattercarpet,
scattergeo,
scattergl,
scattermap,
scattermapbox,
scatterpolar,
scatterpolargl,
Expand Down
7 changes: 7 additions & 0 deletions types/plotly.js/v2/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -666,6 +666,7 @@ export interface Layout {
"yaxis.title": string;
ternary: {}; // TODO
geo: {}; // TODO
map: Partial<Mapbox>;
mapbox: Partial<Mapbox>;
subplot: string;
radialaxis: Partial<Axis>;
Expand Down Expand Up @@ -1278,8 +1279,11 @@ export type ModeBarDefaultButtons =
| "toImage"
| "resetViews"
| "toggleSpikelines"
| "zoomInMap"
| "zoomInMapbox"
| "zoomOutMap"
| "zoomOutMapbox"
| "resetViewMap"
| "resetViewMapbox"
| "togglespikelines"
| "togglehover"
Expand Down Expand Up @@ -1452,10 +1456,12 @@ export type PlotType =
| "candlestick"
| "carpet"
| "choropleth"
| "choroplethmap"
| "choroplethmapbox"
| "cone"
| "contour"
| "contourcarpet"
| "densitymap"
| "densitymapbox"
| "funnel"
| "funnelarea"
Expand All @@ -1479,6 +1485,7 @@ export type PlotType =
| "scattercarpet"
| "scattergeo"
| "scattergl"
| "scattermap"
| "scattermapbox"
| "scatterpolar"
| "scatterpolargl"
Expand Down
4 changes: 4 additions & 0 deletions types/plotly.js/v2/lib/choroplethmap.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const moduleType: "trace";
export const name: "choroplethmap";
export const categories: string[];
export const meta: { description: string };
4 changes: 4 additions & 0 deletions types/plotly.js/v2/lib/densitymap.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const moduleType: "trace";
export const name: "densitymap";
export const categories: string[];
export const meta: { description: string };
4 changes: 4 additions & 0 deletions types/plotly.js/v2/lib/scattermap.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export const moduleType: "trace";
export const name: "scattermap";
export const categories: string[];
export const meta: { description: string };
106 changes: 106 additions & 0 deletions types/plotly.js/v2/test/index-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,112 @@ function rand() {
Plotly.newPlot("myDiv", data, layout);
})();

//////////////////////////////////////////////////////////////////////
// Map plot
(() => {
const data: Array<Partial<PlotData>> = [
{
type: "scattermap",
text: ["A", "B", "C"],
lon: [0, 1, 2],
lat: [0, 1, 2],
marker: { color: "fuchsia", size: 4 },
},
];

const layout: Partial<Layout> = {
dragmode: "zoom",
map: {
accesstoken: "accesstoken",
domain: { x: [0], y: [0], row: 0, column: 0 },
style: "open-street-map",
center: { lat: 0, lon: -0 },
zoom: 3,
bearing: 30,
bounds: { east: 0, west: 0, south: 0, north: 0 },
pitch: 0,
layers: [
{
// Circle layer
visible: true,
sourcetype: "geojson",
source: {
type: "Feature",
properties: {},
geometry: {
type: "Point",
coordinates: [-74.0060, 40.7128],
},
},
type: "circle",
circle: { radius: 10 },
color: "rgb(255, 0, 0)",
opacity: 0.8,
minzoom: 8,
maxzoom: 15,
},
{
// Line layer
visible: true,
sourcetype: "geojson",
source: {
type: "Feature",
geometry: {
type: "LineString",
coordinates: [
[-74.0060, 40.7128],
[-73.9857, 40.7484],
],
},
},
type: "line",
line: {
color: "#00ff00",
width: 2,
dash: "dashdot",
},
opacity: 0.6,
},
{
// Symbol layer
visible: true,
sourcetype: "geojson",
source: {
type: "Feature",
geometry: {
type: "Point",
coordinates: [-73.9857, 40.7484],
},
},
type: "symbol",
symbol: {
icon: "monument",
iconsize: 1.5,
text: "Empire State",
placement: "point",
textposition: "top center",
textfont: font,
},
},
{
// Raster layer
visible: true,
sourcetype: "raster",
source: "mapbox://mapbox.satellite",
type: "raster",
opacity: 0.7,
minzoom: 0,
maxzoom: 22,
},
],
uirevision: "uirevision",
},
margin: { r: 0, t: 0, b: 0, l: 0 },
};

Plotly.newPlot("myDiv", data, layout);
})();

//////////////////////////////////////////////////////////////////////
// Plotly.animate as per https://plot.ly/javascript/animations/
(() => {
Expand Down
Loading