Skip to content

Commit b1d4a92

Browse files
committed
prasnier
1 parent eb1710d commit b1d4a92

2 files changed

Lines changed: 162 additions & 32 deletions

File tree

test/mark-constructors-test.ts

Lines changed: 137 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,47 +8,155 @@ describe("mark constructors", () => {
88
const data = [1, 2, 3];
99

1010
// data + options
11-
class MyArea extends Plot.Area { constructor(data: Plot.Data, options: Plot.AreaOptions) { super(data, options); } }
12-
class MyArrow extends Plot.Arrow { constructor(data: Plot.Data, options: Plot.ArrowOptions) { super(data, options); } }
13-
class MyBarX extends Plot.BarX { constructor(data: Plot.Data, options: Plot.BarXOptions) { super(data, options); } }
14-
class MyBarY extends Plot.BarY { constructor(data: Plot.Data, options: Plot.BarYOptions) { super(data, options); } }
15-
class MyCell extends Plot.Cell { constructor(data: Plot.Data, options: Plot.CellOptions) { super(data, options); } }
16-
class MyContour extends Plot.Contour { constructor(data: Plot.Data, options: Plot.ContourOptions) { super(data, options); } }
17-
class MyDensity extends Plot.Density { constructor(data: Plot.Data, options: Plot.DensityOptions) { super(data, options); } }
18-
class MyDot extends Plot.Dot { constructor(data: Plot.Data, options: Plot.DotOptions) { super(data, options); } }
19-
class MyGeo extends Plot.Geo { constructor(data: Plot.Data, options: Plot.GeoOptions) { super(data, options); } }
20-
class MyImage extends Plot.Image { constructor(data: Plot.Data, options: Plot.ImageOptions) { super(data, options); } }
21-
class MyLine extends Plot.Line { constructor(data: Plot.Data, options: Plot.LineOptions) { super(data, options); } }
22-
class MyLink extends Plot.Link { constructor(data: Plot.Data, options: Plot.LinkOptions) { super(data, options); } }
23-
class MyRaster extends Plot.Raster { constructor(data: Plot.Data, options: Plot.RasterOptions) { super(data, options); } }
24-
class MyRect extends Plot.Rect { constructor(data: Plot.Data, options: Plot.RectOptions) { super(data, options); } }
25-
class MyRuleX extends Plot.RuleX { constructor(data: Plot.Data, options: Plot.RuleXOptions) { super(data, options); } }
26-
class MyRuleY extends Plot.RuleY { constructor(data: Plot.Data, options: Plot.RuleYOptions) { super(data, options); } }
27-
class MyText extends Plot.Text { constructor(data: Plot.Data, options: Plot.TextOptions) { super(data, options); } }
28-
class MyTickX extends Plot.TickX { constructor(data: Plot.Data, options: Plot.TickXOptions) { super(data, options); } }
29-
class MyTickY extends Plot.TickY { constructor(data: Plot.Data, options: Plot.TickYOptions) { super(data, options); } }
30-
class MyTip extends Plot.Tip { constructor(data: Plot.Data, options: Plot.TipOptions) { super(data, options); } }
31-
class MyVector extends Plot.Vector { constructor(data: Plot.Data, options: Plot.VectorOptions) { super(data, options); } }
32-
class MyWaffleX extends Plot.WaffleX { constructor(data: Plot.Data, options: Plot.WaffleXOptions) { super(data, options); } }
33-
class MyWaffleY extends Plot.WaffleY { constructor(data: Plot.Data, options: Plot.WaffleYOptions) { super(data, options); } }
11+
class MyArea extends Plot.Area {
12+
constructor(data: Plot.Data, options: Plot.AreaOptions) {
13+
super(data, options);
14+
}
15+
}
16+
class MyArrow extends Plot.Arrow {
17+
constructor(data: Plot.Data, options: Plot.ArrowOptions) {
18+
super(data, options);
19+
}
20+
}
21+
class MyBarX extends Plot.BarX {
22+
constructor(data: Plot.Data, options: Plot.BarXOptions) {
23+
super(data, options);
24+
}
25+
}
26+
class MyBarY extends Plot.BarY {
27+
constructor(data: Plot.Data, options: Plot.BarYOptions) {
28+
super(data, options);
29+
}
30+
}
31+
class MyCell extends Plot.Cell {
32+
constructor(data: Plot.Data, options: Plot.CellOptions) {
33+
super(data, options);
34+
}
35+
}
36+
class MyContour extends Plot.Contour {
37+
constructor(data: Plot.Data, options: Plot.ContourOptions) {
38+
super(data, options);
39+
}
40+
}
41+
class MyDensity extends Plot.Density {
42+
constructor(data: Plot.Data, options: Plot.DensityOptions) {
43+
super(data, options);
44+
}
45+
}
46+
class MyDot extends Plot.Dot {
47+
constructor(data: Plot.Data, options: Plot.DotOptions) {
48+
super(data, options);
49+
}
50+
}
51+
class MyGeo extends Plot.Geo {
52+
constructor(data: Plot.Data, options: Plot.GeoOptions) {
53+
super(data, options);
54+
}
55+
}
56+
class MyImage extends Plot.Image {
57+
constructor(data: Plot.Data, options: Plot.ImageOptions) {
58+
super(data, options);
59+
}
60+
}
61+
class MyLine extends Plot.Line {
62+
constructor(data: Plot.Data, options: Plot.LineOptions) {
63+
super(data, options);
64+
}
65+
}
66+
class MyLink extends Plot.Link {
67+
constructor(data: Plot.Data, options: Plot.LinkOptions) {
68+
super(data, options);
69+
}
70+
}
71+
class MyRaster extends Plot.Raster {
72+
constructor(data: Plot.Data, options: Plot.RasterOptions) {
73+
super(data, options);
74+
}
75+
}
76+
class MyRect extends Plot.Rect {
77+
constructor(data: Plot.Data, options: Plot.RectOptions) {
78+
super(data, options);
79+
}
80+
}
81+
class MyRuleX extends Plot.RuleX {
82+
constructor(data: Plot.Data, options: Plot.RuleXOptions) {
83+
super(data, options);
84+
}
85+
}
86+
class MyRuleY extends Plot.RuleY {
87+
constructor(data: Plot.Data, options: Plot.RuleYOptions) {
88+
super(data, options);
89+
}
90+
}
91+
class MyText extends Plot.Text {
92+
constructor(data: Plot.Data, options: Plot.TextOptions) {
93+
super(data, options);
94+
}
95+
}
96+
class MyTickX extends Plot.TickX {
97+
constructor(data: Plot.Data, options: Plot.TickXOptions) {
98+
super(data, options);
99+
}
100+
}
101+
class MyTickY extends Plot.TickY {
102+
constructor(data: Plot.Data, options: Plot.TickYOptions) {
103+
super(data, options);
104+
}
105+
}
106+
class MyTip extends Plot.Tip {
107+
constructor(data: Plot.Data, options: Plot.TipOptions) {
108+
super(data, options);
109+
}
110+
}
111+
class MyVector extends Plot.Vector {
112+
constructor(data: Plot.Data, options: Plot.VectorOptions) {
113+
super(data, options);
114+
}
115+
}
116+
class MyWaffleX extends Plot.WaffleX {
117+
constructor(data: Plot.Data, options: Plot.WaffleXOptions) {
118+
super(data, options);
119+
}
120+
}
121+
class MyWaffleY extends Plot.WaffleY {
122+
constructor(data: Plot.Data, options: Plot.WaffleYOptions) {
123+
super(data, options);
124+
}
125+
}
34126

35127
// no data
36-
class MyFrame extends Plot.Frame { constructor(options: Plot.FrameOptions) { super(options); } }
37-
class MyHexgrid extends Plot.Hexgrid { constructor(options: Plot.HexgridOptions) { super(options); } }
128+
class MyFrame extends Plot.Frame {
129+
constructor(options: Plot.FrameOptions) {
130+
super(options);
131+
}
132+
}
133+
class MyHexgrid extends Plot.Hexgrid {
134+
constructor(options: Plot.HexgridOptions) {
135+
super(options);
136+
}
137+
}
38138

39139
it("Area", () => Plot.plot({marks: [new MyArea(data, {x1: Plot.identity, y1: Plot.identity})]}));
40-
it("Arrow", () => Plot.plot({marks: [new MyArrow(data, {x1: Plot.identity, y1: Plot.identity, x2: Plot.identity, y2: Plot.identity})]}));
140+
it("Arrow", () =>
141+
Plot.plot({
142+
marks: [new MyArrow(data, {x1: Plot.identity, y1: Plot.identity, x2: Plot.identity, y2: Plot.identity})]
143+
}));
41144
it("BarX", () => Plot.plot({marks: [new MyBarX(data, {x1: 0, x2: Plot.identity, y: Plot.identity})]}));
42145
it("BarY", () => Plot.plot({marks: [new MyBarY(data, {y1: 0, y2: Plot.identity, x: Plot.identity})]}));
43146
it("Cell", () => Plot.plot({marks: [new MyCell(data, {x: Plot.identity})]}));
44-
it("Contour", () => Plot.plot({marks: [new MyContour(data, {x: Plot.identity, y: Plot.identity, fill: Plot.identity})]}));
147+
it("Contour", () =>
148+
Plot.plot({marks: [new MyContour(data, {x: Plot.identity, y: Plot.identity, fill: Plot.identity})]}));
45149
it("Density", () => Plot.plot({marks: [new MyDensity(data, {x: Plot.identity, y: Plot.identity})]}));
46150
it("Dot", () => Plot.plot({marks: [new MyDot(data, {x: Plot.identity})]}));
47151
it("Geo", () => Plot.plot({marks: [new MyGeo([{type: "Point", coordinates: [0, 0]}], {geometry: Plot.identity})]}));
48152
it("Image", () => Plot.plot({marks: [new MyImage(data, {x: Plot.identity, y: Plot.identity, src: "test.png"})]}));
49153
it("Line", () => Plot.plot({marks: [new MyLine(data, {x: Plot.identity, y: Plot.identity})]}));
50-
it("Link", () => Plot.plot({marks: [new MyLink(data, {x1: Plot.identity, y1: Plot.identity, x2: Plot.identity, y2: Plot.identity})]}));
51-
it("Raster", () => Plot.plot({marks: [new MyRaster(data, {x: Plot.identity, y: Plot.identity, fill: Plot.identity})]}));
154+
it("Link", () =>
155+
Plot.plot({
156+
marks: [new MyLink(data, {x1: Plot.identity, y1: Plot.identity, x2: Plot.identity, y2: Plot.identity})]
157+
}));
158+
it("Raster", () =>
159+
Plot.plot({marks: [new MyRaster(data, {x: Plot.identity, y: Plot.identity, fill: Plot.identity})]}));
52160
it("Rect", () => Plot.plot({marks: [new MyRect(data, {x1: Plot.identity, x2: Plot.identity})]}));
53161
it("RuleX", () => Plot.plot({marks: [new MyRuleX(data, {x: Plot.identity})]}));
54162
it("RuleY", () => Plot.plot({marks: [new MyRuleY(data, {y: Plot.identity})]}));

test/plots/rect-rotate.ts

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ class RotatedRect extends Plot.Rect {
1515
super(data, options);
1616
this.rx = rx;
1717
}
18-
render(index: number[], scales: Plot.ScaleFunctions, values: Plot.ChannelValues, dimensions: Plot.Dimensions, context: Plot.Context) {
18+
render(
19+
index: number[],
20+
scales: Plot.ScaleFunctions,
21+
values: Plot.ChannelValues,
22+
dimensions: Plot.Dimensions,
23+
context: Plot.Context
24+
) {
1925
const g = super.render(index, scales, values, dimensions, context);
2026
if (g) {
2127
let i = 0;
@@ -39,8 +45,24 @@ test(function rectRotate() {
3945
axis: null,
4046
color: {domain: d3.range(10), range: colors},
4147
marks: [
42-
new RotatedRect(d3.range(10), {x1: Plot.identity, x2: (d) => d + 1, y1: 0, y2: 1, fill: Plot.identity, stroke: "white", inset: -2, rx: 8}),
43-
Plot.vector(d3.range(10), {x: (d) => d + 0.5, y: 0.5, rotate: (d) => d * 10, stroke: "white", length: 10, strokeWidth: 1.5})
48+
new RotatedRect(d3.range(10), {
49+
x1: Plot.identity,
50+
x2: (d) => d + 1,
51+
y1: 0,
52+
y2: 1,
53+
fill: Plot.identity,
54+
stroke: "white",
55+
inset: -2,
56+
rx: 8
57+
}),
58+
Plot.vector(d3.range(10), {
59+
x: (d) => d + 0.5,
60+
y: 0.5,
61+
rotate: (d) => d * 10,
62+
stroke: "white",
63+
length: 10,
64+
strokeWidth: 1.5
65+
})
4466
]
4567
});
4668
});

0 commit comments

Comments
 (0)