Skip to content

Commit

Permalink
Merge branch 'main' into 18320-color-picker
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanalvizo committed Jan 17, 2025
2 parents d416763 + 0a1b861 commit c5b13f7
Show file tree
Hide file tree
Showing 20 changed files with 398 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cog.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ disable_changelog = false
# we never tag any code outside the plugins/ directory. Everything else is build glue.
generate_mono_repository_global_tag = false
# limit which branches to perform bumps from
branch_whitelist = [ "main" ]
branch_whitelist = [ "main", "release/*" ]
# we don't really use [skip ci] action filtering, but leaving here in case we decide to someday
skip_ci = "[skip ci]"
skip_untracked = false
Expand Down
7 changes: 6 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@
"useWorkspaces": true,
"useNx": false,
"version": "independent",
"packages": ["plugins/*/src/js/"]
"packages": ["plugins/*/src/js/"],
"command": {
"version": {
"changelogPreset": "conventionalcommits"
}
}
}
24 changes: 23 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@types/node": "^20.11.17",
"@types/prop-types": "^15.7.10",
"@vitejs/plugin-react-swc": "^3.7.0",
"conventional-changelog-conventionalcommits": "^7.0.0",
"eslint": "^8.37.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.6.2",
Expand Down
4 changes: 4 additions & 0 deletions plugins/plotly-express/docs/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@
{
"label": "Multiple axes",
"path": "multiple-axes.md"
},
{
"label": "`unsafe_update_figure` Chart Customization",
"path": "unsafe_update_figure.md"
}
]
}
Expand Down
107 changes: 107 additions & 0 deletions plugins/plotly-express/docs/unsafe-update-figure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# `unsafe_update_figure` Chart Customization

To customize a chart in a way that is not directly supported by Deephaven Plotly Express (`dx`), use the `unsafe_update_figure` parameter.
Every `dx` chart is backed by a Plotly [`Figure`](https://plotly.com/python/figure-structure/). This object gets passed to `unsafe_update_figure` where it can be modified directly. See the [Plotly Figure Reference](https://plotly.com/python/reference/) docs for details on available `Figure` properties.

> [!WARNING]
> Update figure is marked "unsafe" because some modifications can entirely break your figure, and care must be taken.
> `dx` maps `Table` columns to an index of a trace within `Figure.data` which will break if the trace order changes. Do not remove traces. Add new traces at the end of the list.
`unsafe_update_figure` accepts a function that takes a Plotly `Figure` object as input and optionally returns a modified `Figure` object. If a `Figure` is not returned, it is assumed that the input `Figure` has been modified in place.

## Examples

### Bar Line

Add a line to bars in a bar plot with `update_traces`.

```python
import deephaven.plot.express as dx

tips = dx.data.tips()


def update(figure):
# Add a gray line to the bars
figure.update_traces(marker_line_width=3, marker_line_color="gray")


bar_lined_plot = dx.bar(tips, x="Day", unsafe_update_figure=update)
```

### Legend Location

Change the location of the legend to the bottom of the plot by updating the layout.

```python
import deephaven.plot.express as dx

tips = dx.data.tips()


def update(figure):
# Update the layout to move the legend to the bottom
# y is negative to move the legend outside the plot area
figure.update_layout(
legend=dict(orientation="h", yanchor="bottom", y=-0.3, xanchor="left", x=0.3)
)


legend_bottom_plot = dx.scatter(
tips, x="TotalBill", y="Tip", color="Day", unsafe_update_figure=update
)
```

### Vertical Line

Add a vertical line to a plot with `add_vline`.

```python
import deephaven.plot.express as dx

tips = dx.data.tips()


def update(figure):
# Add a dashed orange vertical line at x=20
figure.add_vline(x=20, line_width=3, line_dash="dash", line_color="orange")


scatter_vline_plot = dx.scatter(
tips, x="TotalBill", y="Tip", unsafe_update_figure=update
)
```

### Between Line Fill

Fill the area between lines in a line plot with `fill="tonexty"`.

```python
import deephaven.plot.express as dx

my_table = dx.data.stocks()

# subset data for just DOG transactions and add upper and lower bounds
dog_prices = my_table.where("Sym = `DOG`").update_view(
["UpperPrice = Price + 5", "LowerPrice = Price - 5"]
)


def update(figure):
# tonexty fills the area between the trace and the previous trace in the list
figure.update_traces(
fill="tonexty", fillcolor="rgba(123,67,0,0.3)", selector={"name": "LowerPrice"}
)
figure.update_traces(
fill="tonexty", fillcolor="rgba(123,67,0,0.3)", selector={"name": "Price"}
)


# Order matters for y since the fill is between the trace and the previous trace in the list
filled_line_plot = dx.line(
dog_prices,
x="Timestamp",
y=["UpperPrice", "Price", "LowerPrice"],
unsafe_update_figure=update,
)
```
23 changes: 23 additions & 0 deletions plugins/ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.

- - -
## ui-v0.25.0 - 2025-01-15
#### Bug Fixes
- add menu and menu_trigger to sidebar (#1078) - (49ad632) - dgodinez-dh
- Allow autodoc functions to have no parameters (#1072) - (6b261d6) - Joe
- label prop typing (#1071) - (716b3d9) - Steven Wu
#### Documentation
- use_render_queue, use_liveness_scope, use_table_listener docs (#1044) - (abd691e) - mofojed
- Expand sidebars by default for certain categories, add link to flexbox froggy (#1073) - (e76591d) - Don
- ui.list_view selection_mode (#1070) - (b51373f) - bmingles
- ui as a tree (#1067) - (2e1a725) - dgodinez-dh
- Render Lists (#1061) - (30a1f9f) - dgodinez-dh
- Pure Components (#1064) - (30f3730) - dgodinez-dh
- Using Hooks (#1056) - (28b5a51) - dgodinez-dh
- Component Rules (#1055) - (21e8c5d) - dgodinez-dh
- Update First Component (#1065) - (a6d1aad) - dgodinez-dh
- Conditional Rendering (#1060) - (0ce7634) - dgodinez-dh
#### Features
- ui.menu component (#1076) - (cf23da1) - dgodinez-dh
- ui.logic button (#1050) - (7c83ec2) - ethanalvizo
- add undefined type option (#1026) - (ef7e741) - Steven Wu

- - -

## ui-v0.24.0 - 2024-12-12
#### Bug Fixes
- UI loading duplicate panels in embed iframe (#1043) - (e1559a4) - Matthew Runyon
Expand Down
68 changes: 68 additions & 0 deletions plugins/ui/docs/components/divider.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Divider

Dividers enhance layout clarity by grouping and separating nearby content, helping to establish structure and hierarchy.

## Example

```python
from deephaven import ui


@ui.component
def ui_divider_basic_example():
return ["Content above", ui.divider(), "Content below"]


my_divider_basic_example = ui_divider_basic_example()
```

## Orientation

While aligned horizontally by default, the alignment of the divider can be set using the `orientation` prop.

```python
from deephaven import ui


@ui.component
def ui_divider_orientation_example():
return ui.flex(
"Content before",
ui.divider(orientation="vertical"),
"Content after",
flex_grow=0,
)


my_ui_divider_orientation_example = ui_divider_orientation_example()
```

## Sizing

The thickness of the divider can be set using the `size` prop.

```python
from deephaven import ui


@ui.component
def ui_divider_size_example():
return ui.flex(
"Content below",
ui.divider(size="L"),
"Content above",
ui.divider(size="M"),
"More content above",
ui.divider(size="S"),
direction="column",
)


my_divider_size_example = ui_divider_size_example()
```

## API reference

```{eval-rst}
.. dhautofunction:: deephaven.ui.divider
```
4 changes: 4 additions & 0 deletions plugins/ui/docs/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@
"label": "dialog_trigger",
"path": "components/dialog_trigger.md"
},
{
"label": "divider",
"path": "components/divider.md"
},
{
"label": "flex",
"path": "components/flex.md"
Expand Down
2 changes: 1 addition & 1 deletion plugins/ui/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = deephaven-plugin-ui
description = deephaven.ui plugin
long_description = file: README.md
long_description_content_type = text/markdown
version = 0.24.0.dev0
version = 0.25.0.dev0
url = https://github.com/deephaven/deephaven-plugins
project_urls =
Source Code = https://github.com/deephaven/deephaven-plugins
Expand Down
2 changes: 2 additions & 0 deletions plugins/ui/src/deephaven/ui/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from .date_range_picker import date_range_picker
from .dialog import dialog
from .dialog_trigger import dialog_trigger
from .divider import divider
from .flex import flex
from .form import form
from .fragment import fragment
Expand Down Expand Up @@ -101,6 +102,7 @@
"date_range_picker",
"dialog",
"dialog_trigger",
"divider",
"flex",
"form",
"fragment",
Expand Down
Loading

0 comments on commit c5b13f7

Please sign in to comment.