Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: indicator chart #1088

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

jnumainville
Copy link
Collaborator

@jnumainville jnumainville commented Jan 17, 2025

Adds indicator chart for DH-18091
Note that examples might not work correctly because of deephaven/deephaven-core#6547
Here is some working examples

import deephaven.plot.express as dx
from deephaven import agg as agg
from deephaven import time_table

sym_data = time_table("PT1S").update(["Price = randomDouble(0.0, 5.0)", "StartingPrice = 3", "Sym = (i % 2 == 0) ? `DOG` : `DOG`"]).tail(2).sort(["Sym"])

indicator_plot_basic = dx.indicator(sym_data, value="Price", title="DOG")
indicator_plot_delta = dx.indicator(sym_data, value="Price", reference="StartingPrice")
indicator_plot_text = dx.indicator(sym_data, value="Price", reference="StartingPrice", by="Sym", text="Sym")
indicator_plot_styled = dx.indicator(
    sym_data,
    value="Price",
    reference="StartingPrice",
    text="Sym",
    by="Sym",
    gauge="bullet",
    by_vars=("increasing_color", "decreasing_color", "gauge_color"),
    increasing_color_map={"FISH": "lemonchiffon"},
    decreasing_color_map={"FISH": "salmon"},
    gauge_color_map={"FISH": "chartreuse"},
    increasing_text="Up: ",
    decreasing_text="Down: ",
    prefix="$ ",
    suffix=" (USD)",
    number_format="#,##0.00"
)

Copy link
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add an e2e test in tests/app.d/express.py?

@@ -262,6 +304,7 @@ indicator_plot = dx.indicator(
value="Price",
reference="StartingPrice",
by="Sym",
by_vars=("increasing_color", "decreasing_color"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example is kind of confusing. What is the by_vars argument for? Why are we doing a by here at all when we've already filtered the table to one Sym?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is so that the symbol can be specified in the increasing_color_map and decreasing_color_map, although it shouldn't have filtered to one symbol so I'll fix that.

@@ -69,7 +69,7 @@ def _setup_listeners(self) -> None:
for table, node in self._partitioned_tables.values():
listen_func = partial(self._on_update, node)
# if a table is not refreshing, it will never update, so no need to listen
if table.is_refreshing:
if table and table.is_refreshing:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to have this fix as a separate PR just so it's clear this is fixed in the release notes (is there a ticket for it? When do we run into this issue?)

@@ -30,8 +31,10 @@ def indicator(
suffix: str | None = None,
increasing_text: str | None = "▲",
decreasing_text: str | None = "▼",
number_format: str | None = "#,##0.00",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Autodoc isn't loving this:

ValueError: Missing documentation for deephaven.plot.express.indicator parameters {"##0.00'"}. Verify that parameter names have leading asterisks in the description.

However you're parsing the args, probably just need to check that the comma is at the end, as it seems to pick up the comma in the string right now. Fix that issue in autodoc in a PR before this PR goes through.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I'm removing this default this won't block here, but I'll open another ticket because that needs to be solved eventually.

# this should be safe as it shouldn't appear naturally in a d3 format string
# https://github.com/d3/d3-format/tree/v1.4.5#d3-format
# but isn't a perfect solution
FORMAT_PREFIX = "DEEPHAVEN_JAVA_FORMAT"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of want an = at the end just to denote the end of the "prefix".

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@jnumainville
Copy link
Collaborator Author

I have added some new changes, especially with regards to number format and title. I still need to add unit and e2e tests for these new changes.

This PR is blocked on deephaven/web-client-ui#2352 as well.

jnumainville added a commit to deephaven/web-client-ui that referenced this pull request Feb 4, 2025
These are for deephaven/deephaven-plugins#1088

Currently the layout is only set once, but with indicator it may change,
although specifically the title, so I added an event for that. Not sure
if it's the best approach.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants