Skip to content

Commit 17b52ce

Browse files
authored
Small Viz Fixes (#14447)
- Fix bug with XML in table viz (was erroring as not JSON but JS Object). - Fix single column in scatter plot issue. - Fix database source for scatter plot (both Column and Table). - Fix for Geo Map with database source.
1 parent f9b84d7 commit 17b52ce

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

distribution/lib/Standard/Base/0.0.0-dev/src/Network/Email/Email_Address.enso

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Email_Address
2121
---
2222
default_widget (display : Display = ..Always) -> Widget =
2323
name = [Option "Address" "'[email protected]'"]
24-
name_address = [Option "Name And Address" "..Address '[email protected]' 'Name'"]
24+
name_address = [Option "Name And Address" "(..Address '[email protected]' 'Name')"]
2525
values = name + name_address
2626
Single_Choice values=values display=display
2727

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from Standard.Base import all
22

3+
import Standard.Table.In_Memory_Table.In_Memory_Table
34
from Standard.Table import Table
45

6+
import Standard.Database.DB_Table.DB_Table
7+
58
import project.Helpers
69
from project.Helpers import time_visualization
710

@@ -33,5 +36,6 @@ json_from_table table =
3336
process_to_json_text : Any -> Text
3437
process_to_json_text value = time_visualization Geo_Map ("process_to_json_text: " + value.to_display_text) <|
3538
case value of
36-
_ : Table -> json_from_table value . to_text
39+
_ : DB_Table -> json_from_table (value.read (..First 15000)) . to_text
40+
_ : In_Memory_Table -> json_from_table value . to_text
3741
_ -> value.to_json

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
from Standard.Base import all
22

3+
import Standard.Table.In_Memory_Table.In_Memory_Table
34
from Standard.Table import Column, Table
45

6+
import Standard.Database.DB_Column.DB_Column
7+
import Standard.Database.DB_Table.DB_Table
8+
59
import project.Helpers
610
from project.Helpers import time_visualization
711

@@ -11,7 +15,7 @@ from project.Helpers import time_visualization
1115
Gets the x column from a table.
1216
This is either the column named 'X' or the left most column.
1317
x_column : Table -> Column
14-
x_column table =
18+
x_column table = if table.column_count==1 then Nothing else
1519
by_name = table.get 'X' (table.get 'x')
1620
if Nothing != by_name then by_name else
1721
c = table.at 0
@@ -22,7 +26,7 @@ x_column table =
2226
private: true
2327
---
2428
json_from_table : Table -> Vector Integer | Nothing -> Integer | Nothing -> Text
25-
json_from_table table bounds limit =
29+
json_from_table table bounds limit = if table.column_count==1 && table.column_names.first.equals_ignore_case "x" then json_from_table (table.rename_columns ["Value"] . add_row_number "Index" . reorder_columns ["Index","Value"]) bounds limit else
2630
## Get the x column
2731
col_x = x_column table
2832
if Nothing == col_x then json_from_table (table.add_row_number "x") bounds limit else
@@ -93,9 +97,13 @@ json_from_vector vec bounds limit =
9397
- `value`: the value to be visualized.
9498
process_to_json_text : Any -> Integer | Nothing -> Integer | Nothing -> Text
9599
process_to_json_text value bounds=Nothing limit=Nothing = time_visualization Scatter_Plot ("process_to_json_text: " + value.to_display_text) <|
100+
## If limit is Nothing will use 15,000 for in database operations
96101
json = case value of
97-
_ : Table -> json_from_table value bounds limit
102+
_ : DB_Table -> json_from_table (value.read (..First (limit.if_nothing 15000))) bounds limit
103+
_ : DB_Column -> json_from_table (value.to_table.read (..First (limit.if_nothing 15000))) bounds limit
104+
_ : In_Memory_Table -> json_from_table value bounds limit
105+
_ : Column -> json_from_table value.to_table bounds limit
98106
_ : Vector -> json_from_vector value bounds limit
99-
_ : Column -> json_from_table value.to_table bounds limit
100-
_ -> json_from_vector value.to_vector bounds limit
107+
_ : Array -> json_from_vector value bounds limit
108+
_ -> json_from_vector value.to_vector bounds limit
101109
json

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,8 @@ make_json_for_xml_element xml_element max_items type:Text="XML_Element" =
196196
data = ["data", [map_vector.map .first, map_vector.map .second, map_vector.map i-> i.at 2]]
197197
child_node_action = if type == "XML_Element" then "get" else "get_child_element"
198198
get_child_node_fields = [["get_child_node_action", child_node_action + " {{#key}}"], ["get_child_node_link_name", "key"]]
199-
JS_Object.from_pairs <| [header, data, all_rows, ["type", type]] + get_child_node_fields
199+
js_object = JS_Object.from_pairs <| [header, data, all_rows, ["type", type]] + get_child_node_fields
200+
js_object.to_json
200201

201202
private _make_json_for_db_table t max_rows is_column =
202203
dataframe = t.read (..First max_rows)

0 commit comments

Comments
 (0)