Skip to content

Commit 1248c6d

Browse files
authored
Table Viz fixes (#13782)
- Fix issue with `Column.is_nothing` causing `columns` to not render. - Fix `NaN` and `Infinity` in Table viz.
1 parent ca7f2d5 commit 1248c6d

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

distribution/lib/Standard/Visualization/0.0.0-dev/src/Table/Visualization.enso

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ make_json_for_vector vector max_rows =
8989
all_rows = ["all_rows_count", vector.length]
9090
get_child_node_action = ["get_child_node_action", "at"]
9191
truncated = vector.take max_rows
92-
some_values = truncated.any (v->v.is_nothing.not)
92+
some_values = truncated.any (v-> Nothing!=v)
9393
if some_values.not then JS_Object.from_pairs [["type", "Vector"], all_rows, ["json", truncated.map _make_json_for_value], get_child_node_action] else
9494
matrix = make_json_for_matrix (Builder.new truncated.length) truncated
9595
if matrix.is_nothing.not then JS_Object.from_pairs [["type", "Matrix"], all_rows, ["json", matrix], ["column_count", matrix.fold 0 c->v-> if v.is_nothing then c else c.max v.length], get_child_node_action] else

std-bits/table/src/main/java/org/enso/table/data/column/operation/JsonOperation.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,17 @@ private static String toJson(long value) {
173173
}
174174

175175
private static String toJson(double value) {
176+
if (Double.isNaN(value)) {
177+
return "{\"_display_text_\":\"NaN\",\"type\":\"Float\",\"value\":\"NaN\"}";
178+
}
179+
if (Double.isInfinite(value)) {
180+
var txtValue = value > 0 ? "Infinity" : "-Infinity";
181+
return "{\"_display_text_\":\""
182+
+ txtValue
183+
+ "\",\"type\":\"Float\",\"value\":\""
184+
+ txtValue
185+
+ "\"}";
186+
}
176187
return String.valueOf(value);
177188
}
178189

0 commit comments

Comments
 (0)