Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
jnumainville committed Jan 17, 2025
1 parent dbf372a commit 31bd571
Showing 1 changed file with 48 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class IndicatorTestCase(BaseTestCase):
def setUp(self) -> None:
from deephaven import new_table
from deephaven.column import int_col, string_col
import deephaven.pandas as dhpd

self.source = new_table(
[
Expand All @@ -17,8 +16,6 @@ def setUp(self) -> None:
]
)

self.pandas_source = dhpd.to_pandas(self.source)

def test_basic_indicator(self):
import src.deephaven.plot.express as dx
from deephaven.constants import NULL_INT
Expand Down Expand Up @@ -81,7 +78,7 @@ def test_complex_indicator(self):
"decreasing": {"symbol": "decreasing"},
"increasing": {"symbol": "increasing"},
"prefix": "prefix",
"reference": -2147483648,
"reference": NULL_INT,
"suffix": "suffix",
"valueformat": "DEEPHAVEN_JAVA_FORMAT$#,##0.00",
},
Expand All @@ -95,7 +92,7 @@ def test_complex_indicator(self):
},
"title": {"text": "None"},
"type": "indicator",
"value": -2147483648,
"value": NULL_INT,
}
]

Expand Down Expand Up @@ -132,6 +129,8 @@ def test_by_indicators(self):
chart = dx.indicator(
self.source,
value="value",
reference="reference",
gauge="angular",
by="text",
by_vars=("increasing_color", "decreasing_color", "gauge_color"),
increasing_color_sequence=["salmon", "green", "chocolate"],
Expand All @@ -142,16 +141,23 @@ def test_by_indicators(self):
gauge_color_map={"B": "chartreuse"},
).to_dict(self.exporter)

chart["plotly"]["layout"].pop("template")

expected_data = [
{
"delta": {
"decreasing": {"color": "red", "symbol": "▼"},
"increasing": {"color": "chocolate", "symbol": "▲"},
"reference": NULL_INT,
"valueformat": "DEEPHAVEN_JAVA_FORMAT#,##0.00",
},
"domain": {"x": [0.0, 0.45], "y": [0.0, 0.425]},
"gauge": {"bar": {"color": "orange"}},
"mode": "number",
"gauge": {
"axis": {"visible": True},
"bar": {"color": "orange"},
"shape": "angular",
},
"mode": "number+delta+gauge",
"number": {"valueformat": "DEEPHAVEN_JAVA_FORMAT#,##0.00"},
"type": "indicator",
"value": NULL_INT,
Expand All @@ -160,11 +166,16 @@ def test_by_indicators(self):
"delta": {
"decreasing": {"color": "blue", "symbol": "▼"},
"increasing": {"color": "salmon", "symbol": "▲"},
"reference": NULL_INT,
"valueformat": "DEEPHAVEN_JAVA_FORMAT#,##0.00",
},
"domain": {"x": [0.0, 0.45], "y": [0.575, 1.0]},
"gauge": {"bar": {"color": "pink"}},
"mode": "number",
"gauge": {
"axis": {"visible": True},
"bar": {"color": "pink"},
"shape": "angular",
},
"mode": "number+delta+gauge",
"number": {"valueformat": "DEEPHAVEN_JAVA_FORMAT#,##0.00"},
"type": "indicator",
"value": NULL_INT,
Expand All @@ -173,11 +184,16 @@ def test_by_indicators(self):
"delta": {
"decreasing": {"color": "bisque", "symbol": "▼"},
"increasing": {"color": "salmon", "symbol": "▲"},
"reference": NULL_INT,
"valueformat": "DEEPHAVEN_JAVA_FORMAT#,##0.00",
},
"domain": {"x": [0.55, 1.0], "y": [0.575, 1.0]},
"gauge": {"bar": {"color": "chartreuse"}},
"mode": "number",
"gauge": {
"axis": {"visible": True},
"bar": {"color": "chartreuse"},
"shape": "angular",
},
"mode": "number+delta+gauge",
"number": {"valueformat": "DEEPHAVEN_JAVA_FORMAT#,##0.00"},
"type": "indicator",
"value": NULL_INT,
Expand All @@ -187,9 +203,27 @@ def test_by_indicators(self):
expected_layout = {"legend": {"tracegroupgap": 0}, "margin": {"t": 60}}

expected_mappings = [
{"data_columns": {"value": ["/plotly/data/0/value"]}, "table": 0},
{"data_columns": {"value": ["/plotly/data/1/value"]}, "table": 0},
{"data_columns": {"value": ["/plotly/data/2/value"]}, "table": 0},
{
"data_columns": {
"reference": ["/plotly/data/0/delta/reference"],
"value": ["/plotly/data/0/value"],
},
"table": 0,
},
{
"data_columns": {
"reference": ["/plotly/data/1/delta/reference"],
"value": ["/plotly/data/1/value"],
},
"table": 0,
},
{
"data_columns": {
"reference": ["/plotly/data/2/delta/reference"],
"value": ["/plotly/data/2/value"],
},
"table": 0,
},
]

self.assert_chart_equals(
Expand Down

0 comments on commit 31bd571

Please sign in to comment.