Skip to content

feat: indicator chart#1088

Merged
jnumainville merged 31 commits intodeephaven:mainfrom
jnumainville:18091_indicator
Mar 31, 2025
Merged

feat: indicator chart#1088
jnumainville merged 31 commits intodeephaven:mainfrom
jnumainville:18091_indicator

Conversation

@jnumainville
Copy link
Copy Markdown
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
Copy Markdown
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?

value="Price",
reference="StartingPrice",
by="Sym",
by_vars=("increasing_color", "decreasing_color"),
Copy link
Copy Markdown
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
Copy Markdown
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.

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
Copy Markdown
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?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'm not entirely sure what the issue was here so I have removed the extra check.

suffix: str | None = None,
increasing_text: str | None = "▲",
decreasing_text: str | None = "▼",
number_format: str | None = "#,##0.00",
Copy link
Copy Markdown
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
Copy Markdown
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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

# 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.
@jnumainville
Copy link
Copy Markdown
Collaborator Author

Blocked on pypi/support#5628

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 4, 2025

plotly-express docs preview (Available for 14 days)

@github-actions
Copy link
Copy Markdown

plotly-express docs preview (Available for 14 days)

mofojed pushed a commit to mofojed/web-client-ui that referenced this pull request Mar 26, 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.
mofojed added a commit to deephaven/web-client-ui that referenced this pull request Mar 26, 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.

Co-authored-by: Joe <josephnumainville@deephaven.io>
@github-actions
Copy link
Copy Markdown

plotly-express docs preview (Available for 14 days)

@github-actions
Copy link
Copy Markdown

plotly-express docs preview (Available for 14 days)

@github-actions
Copy link
Copy Markdown

plotly-express docs preview (Available for 14 days)

@jnumainville jnumainville self-assigned this Mar 27, 2025
@jnumainville jnumainville requested a review from mofojed March 27, 2025 18:29
@github-actions
Copy link
Copy Markdown

plotly-express docs preview (Available for 14 days)

@jnumainville
Copy link
Copy Markdown
Collaborator Author

I think we are finally good here barring any other problematic merges beating this one
@margaretkennedy can I get a doc review?

@github-actions
Copy link
Copy Markdown

plotly-express docs preview (Available for 14 days)

mofojed
mofojed previously approved these changes Mar 28, 2025
Comment thread plugins/plotly-express/docs/indicator.md Outdated
Comment thread plugins/plotly-express/docs/indicator.md Outdated
@github-actions
Copy link
Copy Markdown

plotly-express docs preview (Available for 14 days)

@jnumainville jnumainville requested a review from mofojed March 28, 2025 15:40
@jnumainville jnumainville enabled auto-merge (squash) March 28, 2025 15:40
@jnumainville jnumainville merged commit eb835e3 into deephaven:main Mar 31, 2025
17 checks passed
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.

3 participants