Skip to content

Commit

Permalink
Merge branch '579-form' into 418-picker
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanalvizo committed Jul 5, 2024
2 parents 5b93e5a + 512659f commit 92702c4
Show file tree
Hide file tree
Showing 60 changed files with 1,639 additions and 976 deletions.
1,236 changes: 668 additions & 568 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"@types/jest": "^29.2.5",
"@types/node": "^20.11.17",
"@types/prop-types": "^15.7.10",
"@types/shortid": "^0.0.29",
"eslint": "^8.37.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.6.2",
Expand Down
4 changes: 2 additions & 2 deletions plugins/dashboard-object-viewer/src/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"@deephaven/dashboard": "^0.40.0",
"@deephaven/jsapi-types": "^0.40.0",
"@deephaven/log": "^0.40.0",
"react-json-view": "^1.21.3",
"shortid": "^2.2.16"
"nanoid": "^5.0.7",
"react-json-view": "^1.21.3"
},
"devDependencies": {
"@types/react": "^17.0.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect } from 'react';
import shortid from 'shortid';
import { nanoid } from 'nanoid';
import type { DashboardPluginComponentProps } from '@deephaven/dashboard';
import LayoutUtils from '@deephaven/dashboard/dist/layout/LayoutUtils';
import { useListener } from '@deephaven/dashboard/dist/layout/hooks';
Expand All @@ -19,7 +19,7 @@ export function DashboardPlugin({
({
dragEvent,
fetch,
panelId = shortid.generate(),
panelId = nanoid(),
widget,
}: {
dragEvent?: DragEvent;
Expand Down
3 changes: 1 addition & 2 deletions plugins/matplotlib/src/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
"@deephaven/jsapi-bootstrap": "^0.58.0",
"@deephaven/jsapi-types": "^0.58.0",
"@deephaven/log": "^0.58.0",
"@deephaven/plugin": "^0.58.0",
"shortid": "^2.2.16"
"@deephaven/plugin": "^0.58.0"
},
"publishConfig": {
"access": "public"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ def get_index(species: str) -> int:
"timestamp = base_time + (long)((ii + df_len) * SECOND)",
# pick a random species from the list, using the index as a seed
"species = (String)species_list[(int)new Random(ii).nextInt(3)]",
"sepal_length = get_random_value(`sepal_length`, ii, species)",
"sepal_width = get_random_value(`sepal_width`, ii, species)",
"petal_length = get_random_value(`petal_length`, ii, species)",
"petal_width = get_random_value(`petal_width`, ii, species)",
"sepal_length = get_random_value(`sepal_length`, ii + 1, species)",
"sepal_width = get_random_value(`sepal_width`, ii + 2, species)",
"petal_length = get_random_value(`petal_length`, ii + 3, species)",
"petal_width = get_random_value(`petal_width`, ii + 4, species)",
"species_id = get_index(species)",
]
)
Expand All @@ -125,6 +125,135 @@ def get_index(species: str) -> int:
return source_table


def jobs(ticking: bool = True) -> Table:
"""
Returns a synthetic dataset containing five different jobs and their durations over time.
This dataset is intended to be used with a timeline plot. It demonstrates five different "jobs", each starting
two days after the previous, and each lasting 5 days in total. The job's "resource", or the name of the individual
assigned to the job, is randomly selected. The dataset continues to loop in this way, moving across time until
it is deleted or the server is shut down.
Notes:
Contains the following columns:
- Job: a string column denoting the name of the job, ranging from Job1 to Job5
- StartTime: a Java Instant column containing the start time of the job
- EndTime: a Java Instant column containing the end time of the job
- Resource: a string column indicating the name of the person that the job is assigned to
Args:
ticking:
If true, the table will tick new data every second.
Returns:
A Deephaven Table
Examples:
```
from deephaven.plot import express as dx
jobs = dx.data.jobs()
```
"""

def generate_resource(index: int) -> str:
random.seed(index)
return random.choice(["Mike", "Matti", "Steve", "John", "Jane"])

jobs_query_strings = [
"Job = `Job` + String.valueOf((ii % 5) + 1)",
"StartTime = '2020-01-01T00:00:00Z' + ('P1d' * i * 2)",
"EndTime = StartTime + 'P5d'",
"Resource = generate_resource(ii)",
]

static_jobs = empty_table(5).update(jobs_query_strings)

if not ticking:
return static_jobs

ticking_jobs = merge(
[
static_jobs,
time_table("PT1s")
.drop_columns("Timestamp")
.update(jobs_query_strings)
.update("StartTime = StartTime + 'P10d'"),
]
).last_by("Job")

return ticking_jobs


def marketing(ticking: bool = True) -> Table:
"""
Returns a synthetic ticking dataset tracking the movement of customers from website visit to product purchase.
This dataset is intended to be used with the `dx.funnel` and `dx.funnel_area` plot types. Each row in this dataset
represents an individual that has visited a company website. The individual may download an instance of the product,
be considered a potential customer, formally request the price of the product, or purchase the product and receive
an invoice. Each of these categories is a strict subset of the last, so it lends itself well to funnel plots.
Notes:
Contains the following columns:
- Stage: a string column containing the stage of a customers interest:
VisitedWebsite, Downloaded, PotentialCustomer, RequestedPrice, and InvoiceSent
- Count: an integer column counting the number of customers to fall into each category
Args:
ticking:
If true, the table will tick new data every second.
Returns:
A Deephaven Table
Examples:
```
from deephaven.plot import express as dx
marketing = dx.data.marketing()
```
"""
_ColsToRowsTransform = jpy.get_type(
"io.deephaven.engine.table.impl.util.ColumnsToRowsTransform"
)

def weighted_selection(prob: float, index: int) -> bool:
random.seed(index)
return random.uniform(0, 1) < prob

marketing_query_strings = [
"VisitedWebsite = true", # appearing in this table assumes a website visit
"Downloaded = VisitedWebsite ? weighted_selection(0.45, ii) : false", # 45% of visits download product
"PotentialCustomer = Downloaded ? weighted_selection(0.77, ii + 1) : false", # 77% of downloads are potential customers
"RequestedPrice = PotentialCustomer ? weighted_selection(0.82, ii + 2) : false", # 82% of flagged potential customers request price
"InvoiceSent = RequestedPrice ? weighted_selection(0.24, ii + 3) : false", # 24% of those who requested price get invoice
]

marketing_table = empty_table(100).update(marketing_query_strings)

if ticking:
marketing_table = merge(
[
marketing_table,
time_table("PT1s")
.update(marketing_query_strings)
.drop_columns("Timestamp"),
]
)

return Table(
_ColsToRowsTransform.columnsToRows(
marketing_table.sum_by().j_table,
"Stage",
"Count",
"VisitedWebsite",
"Downloaded",
"PotentialCustomer",
"RequestedPrice",
"InvoiceSent",
)
)


def stocks(ticking: bool = True, hours_of_data: int = 1) -> Table:
"""Returns a Deephaven table containing a generated example data set.
Expand Down Expand Up @@ -353,23 +482,23 @@ def generate_sex(index: int) -> str:
return random.choices(sex_list, weights=sex_probs)[0]

def generate_smoker(index: int) -> str:
random.seed(index)
random.seed(index + 1)
return random.choices(smoker_list, weights=smoker_probs)[0]

def generate_day(index: int) -> str:
random.seed(index)
random.seed(index + 2)
return random.choices(day_list, weights=day_probs)[0]

def generate_time(index: int) -> str:
random.seed(index)
random.seed(index + 3)
return random.choices(time_list, weights=time_probs)[0]

def generate_size(index: int) -> int:
random.seed(index)
random.seed(index + 4)
return random.choices(size_list, weights=size_probs)[0]

def generate_total_bill(smoker: str, size: int, index: int) -> float:
random.seed(index)
random.seed(index + 5)
return round(
3.68
+ 3.08 * (smoker == "Yes")
Expand All @@ -379,7 +508,7 @@ def generate_total_bill(smoker: str, size: int, index: int) -> float:
)

def generate_tip(total_bill: float, index: int) -> float:
random.seed(index)
random.seed(index + 6)
return max(1, round(0.92 + 0.11 * total_bill + random.gauss(0.0, 1.02), 2))

# create synthetic ticking version of the tips dataset that generates one new observation per period
Expand All @@ -403,7 +532,7 @@ def generate_tip(total_bill: float, index: int) -> float:
return merge([tips_table, ticking_table])


def election(ticking: bool = True):
def election(ticking: bool = True) -> Table:
"""
Returns a ticking version of the Election dataset included in the plotly-express package.
Expand Down Expand Up @@ -488,7 +617,7 @@ def get_long_val(column: str, index: int) -> int:
return merge([election_table.head(STATIC_ROWS - 1), ticking_table])


def wind(ticking: bool = True):
def wind(ticking: bool = True) -> Table:
"""
Returns a ticking version of the Wind dataset included in the plotly-express package.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

from numbers import Number
from typing import Callable

from plotly import express as px
Expand Down Expand Up @@ -38,8 +37,8 @@ def bar(
| dict[str | tuple[str], str]
| None = None,
color_continuous_scale: list[str] | None = None,
range_color: list[Number] | None = None,
color_continuous_midpoint: Number | None = None,
range_color: list[float] | None = None,
color_continuous_midpoint: float | None = None,
opacity: float | None = None,
barmode: str = "relative",
log_x: bool = False,
Expand Down Expand Up @@ -221,8 +220,8 @@ def timeline(
| dict[str | tuple[str], str]
| None = None,
color_continuous_scale: list[str] | None = None,
range_color: list[Number] | None = None,
color_continuous_midpoint: Number | None = None,
range_color: list[float] | None = None,
color_continuous_midpoint: float | None = None,
opacity: float | None = None,
range_x: list[int] | None = None,
range_y: list[int] | None = None,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

from numbers import Number
from typing import Callable

from plotly import express as px
Expand All @@ -23,8 +22,8 @@ def treemap(
color_discrete_sequence: list[str] | None = None,
color_discrete_map: dict[str | tuple[str], str] | None = None,
color_continuous_scale: list[str] | None = None,
range_color: list[Number] | None = None,
color_continuous_midpoint: Number | None = None,
range_color: list[float] | None = None,
color_continuous_midpoint: float | None = None,
labels: dict[str, str] | None = None,
title: str | None = None,
template: str | None = None,
Expand Down Expand Up @@ -91,8 +90,8 @@ def sunburst(
color_discrete_sequence: list[str] | None = None,
color_discrete_map: dict[str | tuple[str], str] | None = None,
color_continuous_scale: list[str] | None = None,
range_color: list[Number] | None = None,
color_continuous_midpoint: Number | None = None,
range_color: list[float] | None = None,
color_continuous_midpoint: float | None = None,
labels: dict[str, str] | None = None,
title: str | None = None,
template: str | None = None,
Expand Down Expand Up @@ -159,8 +158,8 @@ def icicle(
color_discrete_sequence: list[str] | None = None,
color_discrete_map: dict[str | tuple[str], str] | None = None,
color_continuous_scale: list[str] | None = None,
range_color: list[Number] | None = None,
color_continuous_midpoint: Number | None = None,
range_color: list[float] | None = None,
color_continuous_midpoint: float | None = None,
labels: dict[str, str] | None = None,
title: str | None = None,
template: str | None = None,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import annotations

from numbers import Number
from typing import Callable

from plotly import express as px
Expand Down Expand Up @@ -41,8 +40,8 @@ def scatter_geo(
| dict[str | tuple[str], str]
| None = None,
color_continuous_scale: list[str] | None = None,
range_color: list[Number] | None = None,
color_continuous_midpoint: Number | None = None,
range_color: list[float] | None = None,
color_continuous_midpoint: float | None = None,
opacity: float | None = None,
projection: str | None = None,
scope: str | None = None,
Expand Down Expand Up @@ -175,8 +174,8 @@ def scatter_mapbox(
| dict[str | tuple[str], str]
| None = None,
color_continuous_scale: list[str] | None = None,
range_color: list[Number] | None = None,
color_continuous_midpoint: Number | None = None,
range_color: list[float] | None = None,
color_continuous_midpoint: float | None = None,
opacity: float | None = None,
zoom: float | None = None,
center: dict[str, float] | None = None,
Expand Down
Loading

0 comments on commit 92702c4

Please sign in to comment.