Skip to content

Commit 3372bae

Browse files
committed
refactor method signature
1 parent 03cadb8 commit 3372bae

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

jsplot/src/main/java/tech/tablesaw/plotly/api/BubblePlot.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package tech.tablesaw.plotly.api;
22

33
import java.util.List;
4+
import tech.tablesaw.api.NumericColumn;
45
import tech.tablesaw.api.Table;
5-
import tech.tablesaw.columns.Column;
66
import tech.tablesaw.plotly.components.Figure;
77
import tech.tablesaw.plotly.components.Layout;
88
import tech.tablesaw.plotly.components.Marker;
@@ -40,23 +40,21 @@ public static Figure create(
4040
return new Figure(layout, traces);
4141
}
4242

43-
public static Figure create(
43+
private static Figure create(
4444
String title,
45-
Table table,
46-
String xCol,
47-
Column xColumn,
48-
String yCol,
49-
Column yColumn,
50-
String sizeColumn,
45+
NumericColumn xColumn,
46+
NumericColumn yColumn,
47+
NumericColumn sizeColumn,
5148
double[] color,
5249
SizeMode sizeMode,
5350
Double opacity) {
54-
Layout layout = Layout.builder(title, xCol, yCol).build();
51+
52+
Layout layout = Layout.builder(title, xColumn.name(), yColumn.name()).build();
5553

5654
Marker marker = null;
5755
MarkerBuilder builder = Marker.builder();
5856
if (sizeColumn != null) {
59-
builder.size(table.numberColumn(sizeColumn));
57+
builder.size(sizeColumn);
6058
}
6159
if (opacity != null) {
6260
builder.opacity(opacity);
@@ -69,16 +67,15 @@ public static Figure create(
6967
}
7068
marker = builder.build();
7169

72-
xColumn = (xColumn == null) ? table.numberColumn(xCol) : xColumn;
73-
yColumn = (yColumn == null) ? table.numberColumn(yCol) : yColumn;
74-
7570
ScatterTrace trace = ScatterTrace.builder(xColumn, yColumn).marker(marker).build();
7671
return new Figure(layout, trace);
7772
}
7873

79-
public static Figure create(
80-
String title, Table table, String xCol, String yCol, String sizeColumn) {
81-
return create(title, table, xCol, null, yCol, null, sizeColumn, null, null, null);
74+
public static Figure create(String title, Table table, String xCol, String yCol, String sizeCol) {
75+
NumericColumn xColumn = table.numberColumn(xCol);
76+
NumericColumn yColumn = table.numberColumn(yCol);
77+
NumericColumn sizeColumn = table.numberColumn(sizeCol);
78+
return create(title, xColumn, yColumn, sizeColumn, null, null, null);
8279
}
8380

8481
public static Figure create(

0 commit comments

Comments
 (0)