Skip to content

Commit 41d354d

Browse files
committed
Plotly v3 - Drop transforms from the API
plotly/plotly.js#7240, plotly/plotly.js#7254
1 parent 02ce8a0 commit 41d354d

File tree

7 files changed

+4
-119
lines changed

7 files changed

+4
-119
lines changed

types/plotly.js/index.d.ts

+1-57
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,6 @@ export type Color =
13101310
| Array<string | number | undefined | null>
13111311
| Array<Array<string | number | undefined | null>>;
13121312
export type ColorScale = string | string[] | Array<[number, string]>;
1313-
export type DataTransform = Partial<Transform>;
13141313
export type ScatterData = PlotData;
13151314

13161315
export interface PlotData {
@@ -1474,7 +1473,6 @@ export interface PlotData {
14741473
delta: Partial<Delta>;
14751474
gauge: Partial<Gauge>;
14761475
number: Partial<PlotNumber>;
1477-
transforms: DataTransform[];
14781476
orientation: "v" | "h";
14791477
width: number | number[];
14801478
boxmean: boolean | "sd";
@@ -1543,48 +1541,6 @@ export interface PlotData {
15431541
uid: string;
15441542
}
15451543

1546-
/**
1547-
* These interfaces are based on attribute descriptions in
1548-
* https://github.com/plotly/plotly.js/tree/9d6144304308fc3007f0facf2535d38ea3e9b26c/src/transforms
1549-
*/
1550-
export interface TransformStyle {
1551-
target: number | string | number[] | string[];
1552-
value: Partial<PlotData>;
1553-
}
1554-
1555-
export interface TransformAggregation {
1556-
target: string;
1557-
func?:
1558-
| "count"
1559-
| "sum"
1560-
| "avg"
1561-
| "median"
1562-
| "mode"
1563-
| "rms"
1564-
| "stddev"
1565-
| "min"
1566-
| "max"
1567-
| "first"
1568-
| "last"
1569-
| undefined;
1570-
funcmode?: "sample" | "population" | undefined;
1571-
enabled?: boolean | undefined;
1572-
}
1573-
1574-
export interface Transform {
1575-
type: "aggregate" | "filter" | "groupby" | "sort";
1576-
enabled: boolean;
1577-
target: number | string | number[] | string[];
1578-
operation: string;
1579-
aggregations: TransformAggregation[];
1580-
preservegaps: boolean;
1581-
groups: string | number[] | string[];
1582-
nameformat: string;
1583-
styles: TransformStyle[];
1584-
value: any;
1585-
order: "ascending" | "descending";
1586-
}
1587-
15881544
export interface ColorBarTitle {
15891545
text: string;
15901546
font: Partial<Font>;
@@ -1880,9 +1836,6 @@ export interface Config {
18801836
*/
18811837
logging: boolean | 0 | 1 | 2;
18821838

1883-
/** Set global transform to be applied to all traces with no specification needed */
1884-
globalTransforms: any[];
1885-
18861839
/** Which localization should we use? Should be a string like 'en' or 'en-US' */
18871840
locale: string;
18881841

@@ -2746,15 +2699,6 @@ interface LocaleModule {
27462699
format: Record<string, unknown>;
27472700
}
27482701

2749-
interface TransformModule {
2750-
moduleType: "transform";
2751-
name: string;
2752-
transform: any;
2753-
calcTransform: any;
2754-
attributes: Record<string, unknown>;
2755-
supplyDefaults: any;
2756-
}
2757-
27582702
interface ComponentModule {
27592703
moduleType: "component";
27602704
name: string;
@@ -2766,4 +2710,4 @@ interface ApiMethodModule {
27662710
fn: any;
27672711
}
27682712

2769-
type PlotlyModule = TraceModule | LocaleModule | TransformModule | ComponentModule | ApiMethodModule;
2713+
type PlotlyModule = TraceModule | LocaleModule | ComponentModule | ApiMethodModule;

types/plotly.js/lib/aggregate.d.ts

-6
This file was deleted.

types/plotly.js/lib/filter.d.ts

-6
This file was deleted.

types/plotly.js/lib/groupby.d.ts

-6
This file was deleted.

types/plotly.js/lib/sort.d.ts

-6
This file was deleted.

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

+3-30
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ const graphDiv = "#test";
66
//////////////////////////////////////////////////////////////////////
77
// Plotly.newPlot
88
// combination of https://plotly.com/javascript/multiple-transforms/#all-transforms and
9-
// https://plotly.com/javascript/2d-density-plots/
9+
// https://plotly.com/javascript/2d-density-plots/, but with transforms removed as they
10+
// no longer exist in Plotly v3 (it's up to you to massage the data set before passing
11+
// it to Plotly, rather than letting Plotly do the transform for you).
1012

1113
(() => {
1214
const testrows = [
@@ -74,35 +76,6 @@ const graphDiv = "#test";
7476
},
7577
},
7678
type: "scatter",
77-
transforms: [
78-
{
79-
type: "filter",
80-
target: unpack(testrows, "year"),
81-
operation: "=",
82-
value: "2002",
83-
},
84-
{
85-
type: "groupby",
86-
nameformat: `%{group}`,
87-
groups: unpack(testrows, "continent"),
88-
styles: [
89-
{ target: "Asia", value: { marker: { color: "red" } } },
90-
{ target: "Europe", value: { marker: { color: "blue" } } },
91-
{ target: "Americas", value: { marker: { color: "orange" } } },
92-
{ target: "Africa", value: { marker: { color: "green" } } },
93-
{ target: "Oceania", value: { marker: { color: "purple" } } },
94-
],
95-
},
96-
{
97-
type: "aggregate",
98-
groups: unpack(testrows, "continent"),
99-
aggregations: [
100-
{ target: "x", func: "avg" },
101-
{ target: "y", func: "avg" },
102-
{ target: "marker.size", func: "sum" },
103-
],
104-
},
105-
],
10679
width: 2,
10780
} as PlotData;
10881
const trace2 = {

types/plotly.js/test/register-tests.ts

-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import aggregate from "plotly.js/lib/aggregate";
21
import bar from "plotly.js/lib/bar";
32
import barpolar from "plotly.js/lib/barpolar";
43
import box from "plotly.js/lib/box";
@@ -12,10 +11,8 @@ import contour from "plotly.js/lib/contour";
1211
import contourcarpet from "plotly.js/lib/contourcarpet";
1312
import Plotly from "plotly.js/lib/core";
1413
import densitymapbox from "plotly.js/lib/densitymapbox";
15-
import filter from "plotly.js/lib/filter";
1614
import funnel from "plotly.js/lib/funnel";
1715
import funnelarea from "plotly.js/lib/funnelarea";
18-
import groupby from "plotly.js/lib/groupby";
1916
import heatmap from "plotly.js/lib/heatmap";
2017
import histogram from "plotly.js/lib/histogram";
2118
import histogram2d from "plotly.js/lib/histogram2d";
@@ -40,7 +37,6 @@ import scatterpolar from "plotly.js/lib/scatterpolar";
4037
import scatterpolargl from "plotly.js/lib/scatterpolargl";
4138
import scattersmith from "plotly.js/lib/scattersmith";
4239
import scatterternary from "plotly.js/lib/scatterternary";
43-
import sort from "plotly.js/lib/sort";
4440
import splom from "plotly.js/lib/splom";
4541
import streamtube from "plotly.js/lib/streamtube";
4642
import sunburst from "plotly.js/lib/sunburst";
@@ -52,7 +48,6 @@ import volume from "plotly.js/lib/volume";
5248
import waterfall from "plotly.js/lib/waterfall";
5349

5450
Plotly.register([
55-
aggregate,
5651
bar,
5752
barpolar,
5853
box,
@@ -65,10 +60,8 @@ Plotly.register([
6560
contour,
6661
contourcarpet,
6762
densitymapbox,
68-
filter,
6963
funnel,
7064
funnelarea,
71-
groupby,
7265
heatmap,
7366
histogram,
7467
histogram2d,
@@ -93,7 +86,6 @@ Plotly.register([
9386
scatterpolargl,
9487
scattersmith,
9588
scatterternary,
96-
sort,
9789
splom,
9890
streamtube,
9991
sunburst,

0 commit comments

Comments
 (0)