-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 18320-color-picker
- Loading branch information
Showing
20 changed files
with
398 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.