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
12 changes: 12 additions & 0 deletions types/plotly.js/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export interface Mapbox {
pitch: number;
layers: Array<Partial<MapboxLayers>>;
uirevision: number | string;
uid: string;
}

export interface SliderChangeEvent {
Expand Down Expand Up @@ -338,6 +339,7 @@ export interface PolarLayout {
angularaxis: Partial<LayoutAxis>;
gridshape: 'circular' | 'linear';
uirevision: string | number;
uid: string;
}

export interface PlotlyDataLayoutConfig {
Expand Down Expand Up @@ -513,6 +515,7 @@ export interface Layout {
template: Template;
clickmode: 'event' | 'select' | 'event+select' | 'none';
uirevision: number | string;
uid: string;
datarevision: number | string;
editrevision: number | string;
selectionrevision: number | string;
Expand All @@ -532,6 +535,7 @@ export interface Legend extends Label {
tracegroupgap: number;
traceorder: 'grouped' | 'normal' | 'reversed' | 'reversed+grouped';
uirevision: number | string;
uid: string;
valign: 'top' | 'middle' | 'bottom';
x: number;
xanchor: 'auto' | 'left' | 'center' | 'right';
Expand Down Expand Up @@ -910,6 +914,7 @@ export interface ModeBar {
orientation: 'v' | 'h';
remove: ModeBarDefaultButtons | ModeBarDefaultButtons[];
uirevision: number | string;
uid: string;
}

export type ModeBarButtonAny = ModeBarDefaultButtons | ModeBarButton;
Expand Down Expand Up @@ -1319,6 +1324,11 @@ export interface PlotData {
fillpattern: Partial<Pattern>;
showlegend: boolean;
legendgroup: string;
legendgrouptitle: {
text: string;
font?: Partial<Font>;
};
legendrank: number;
parents: string[];
name: string;
stackgroup: string;
Expand Down Expand Up @@ -1393,6 +1403,8 @@ export interface PlotData {
}>;
autocontour: boolean;
ncontours: number;
uirevision: string | number;
uid: string;
}

/**
Expand Down
38 changes: 19 additions & 19 deletions types/plotly.js/test/core-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ViolinData,
CandlestickData,
PieData,
SankeyData
SankeyData,
} from 'plotly.js/lib/core';

const graphDiv = '#test';
Expand Down Expand Up @@ -145,30 +145,30 @@ const layout = {
(() => {
const data: Array<Partial<SankeyData>> = [
{
type: "sankey",
orientation: "h",
type: 'sankey',
orientation: 'h',
node: {
pad: 15,
thickness: 30,
line: {
color: "black",
width: 0.5
},
label: ["A1", "A2", "B1", "B2", "C1", "C2"],
color: ["blue", "blue", "blue", "blue", "blue", "blue"]
pad: 15,
thickness: 30,
line: {
color: 'black',
width: 0.5,
},
label: ['A1', 'A2', 'B1', 'B2', 'C1', 'C2'],
color: ['blue', 'blue', 'blue', 'blue', 'blue', 'blue'],
},
link: {
source: [0, 1, 0, 2, 3, 3],
target: [2, 3, 3, 4, 4, 5],
value: [8, 4, 2, 8, 4, 2]
}
}
source: [0, 1, 0, 2, 3, 3],
target: [2, 3, 3, 4, 4, 5],
value: [8, 4, 2, 8, 4, 2],
},
},
];
const layout = {
title: "Basic Sankey",
title: 'Basic Sankey',
font: {
size: 10
}
size: 10,
},
};
Plotly.newPlot(graphDiv, data, layout);
})();
Expand Down
68 changes: 36 additions & 32 deletions types/plotly.js/test/index-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,13 @@ const graphDiv = '#test';
const template: Template = {
data: {
bar: [{ marker: { color: '#3183BD', opacity: 0.7 }, textposition: 'auto' }],
scatter: [{
mode: 'lines+markers',
line: { color: 'red', width: 3 },
marker: { color: 'red', size: 8, symbol: 'circle-open' },
}],
scatter: [
{
mode: 'lines+markers',
line: { color: 'red', width: 3 },
marker: { color: 'red', size: 8, symbol: 'circle-open' },
},
],
},
layout: { barmode: 'stack', showlegend: false, xaxis: { tickangle: -45 } },
};
Expand Down Expand Up @@ -348,7 +350,7 @@ const graphDiv = '#test';
transform: 'matrix(1 0 0 -1 0 850)',
},
click: (gd, ev) => console.log('Download data'),
}
},
],
setBackground: 'transparent',
watermark: false,
Expand Down Expand Up @@ -992,9 +994,9 @@ function rand() {
const z: number[][] = [];
for (let ydx = 0; ydx < Steps; ydx++) {
const _z = new Array<number>(Steps);
const y = -Span + ydx * 2 * Span / Steps;
const y = -Span + (ydx * 2 * Span) / Steps;
for (let xdx = 0; xdx < Steps; xdx++) {
const x = -Span + xdx * 2 * Span / Steps;
const x = -Span + (xdx * 2 * Span) / Steps;
_z[xdx] = Math.sqrt(x * x + y * y);
}
z.push(_z);
Expand All @@ -1008,7 +1010,7 @@ function rand() {
coloring: 'lines',
labelfont: {
color: 'black',
family: 'monospace'
family: 'monospace',
},
showlabels: true,
},
Expand All @@ -1027,27 +1029,29 @@ function rand() {
const button1: Partial<Plotly.UpdateMenuButton> = {
args: ['visible', [true, false]],
label: 'Trace 1',
method: 'restyle'
method: 'restyle',
};

const button2: Partial<Plotly.UpdateMenuButton> = {
args: ['visible', [true, false]],
label: 'Trace 1',
method: 'restyle'
method: 'restyle',
};

const layout: Partial<Plotly.Layout> = {
updatemenus: [{
buttons: [button1, button2],
direction: 'down',
pad: { r: 10, t: 10 },
showactive: true,
type: 'dropdown',
x: 0.1,
xanchor: 'left',
y: 1.1,
yanchor: 'top'
}],
updatemenus: [
{
buttons: [button1, button2],
direction: 'down',
pad: { r: 10, t: 10 },
showactive: true,
type: 'dropdown',
x: 0.1,
xanchor: 'left',
y: 1.1,
yanchor: 'top',
},
],
};

const data: Array<Partial<PlotData>> = [
Expand All @@ -1063,33 +1067,33 @@ function rand() {

//////////////////////////////////////////////////////////////////////
// PlotlyIcons
(() => {
() => {
const icon = Plotly.Icons.home;
const icon2 = Plotly.Icons.undo;
});
};

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

const layout: Partial<Layout> = {
dragmode: "zoom",
mapbox: { style: "open-street-map", center: { lat: 0, lon: -0 }, zoom: 3 },
margin: { r: 0, t: 0, b: 0, l: 0 }
dragmode: 'zoom',
mapbox: { style: 'open-street-map', center: { lat: 0, lon: -0 }, zoom: 3 },
margin: { r: 0, t: 0, b: 0, l: 0 },
};

const config: Partial<Config> = {
modeBarButtonsToRemove: ['resetViewMapbox', 'zoomInMapbox', 'zoomOutMapbox']
modeBarButtonsToRemove: ['resetViewMapbox', 'zoomInMapbox', 'zoomOutMapbox'],
};

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