Skip to content

Commit

Permalink
feat: Support Gantt plots with time scale.
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Oct 3, 2023
1 parent f8fb86f commit 48840c5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
8 changes: 4 additions & 4 deletions ui/src/plot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,9 @@ export const
}

const
isF = (x: any): x is number => typeof x === 'number',
isB = (x: any): x is boolean => typeof x === 'boolean',
isS = (x: any): x is string => typeof x === 'string',
isF = (x: unknown): x is number => typeof x === 'number',
isB = (x: unknown): x is boolean => typeof x === 'boolean',
isS = (x: unknown): x is string => typeof x === 'string',
split = (s: S) => s.trim().split(/\s+/g),
parseInts = (s: S) => split(s).map(s => parseInt(s, 10)),
convertToDates = (ds: any[], f: S) => {
Expand Down Expand Up @@ -939,7 +939,7 @@ const

const
type = getCoordType(marks) as any,
transpose = space === SpaceT.CD,
transpose = space === SpaceT.CD || space === SpaceT.TD,
actions: CoordinateActions[] | undefined = transpose ? [['transpose']] : undefined

if (transpose) for (const mark of marks) transposeMark(mark)
Expand Down
23 changes: 22 additions & 1 deletion website/widgets/plots/interval.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ q.page['example'] = ui.plot_card(

## Range

Make a column plot with each bar representing high/low (or start/end) values. Transposing this produces a Gantt plot.
Make a column plot with each bar representing high/low (or start/end) values.

```py
from h2o_wave import data
Expand All @@ -158,6 +158,27 @@ q.page['example'] = ui.plot_card(
)
```

## Gantt

Make a Gantt plot with each bar representing high/low (or start/end) values.

```py
from h2o_wave import data

q.page['example'] = ui.plot_card(
box='1 1 4 5',
title='Interval, range',
data=data('profession max min', 5, rows=[
('medicine', '2022-01-01', '2020-01-01'),
('fire fighting', '2021-06-01', '2021-01-01'),
('pedagogy', '2020-06-01', '2022-01-01'),
('psychology', '2021-01-01', '2022-01-01'),
('computer science', '2020-01-01', '2022-01-01'),
]),
plot=ui.plot([ui.mark(type='interval', y='=profession', x_scale='time', x0='=min', x='=max')])
)
```

## Polar

Make a rose plot (a bar plot in polar coordinates).
Expand Down

0 comments on commit 48840c5

Please sign in to comment.