-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement
useGeometry
hook to ease creation/update of geometries
- Loading branch information
Showing
28 changed files
with
971 additions
and
405 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { | ||
DefaultInteractions, | ||
ErrorBars, | ||
useDomain, | ||
VisCanvas, | ||
} from '@h5web/lib'; | ||
import { assertDefined, mockValues, ScaleType } from '@h5web/shared'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { range } from 'lodash'; | ||
|
||
import FillHeight from './decorators/FillHeight'; | ||
|
||
const meta = { | ||
title: 'Building Blocks/ErrorBars', | ||
component: ErrorBars, | ||
decorators: [FillHeight], | ||
parameters: { | ||
layout: 'fullscreen', | ||
controls: { sort: 'requiredFirst' }, | ||
}, | ||
args: { | ||
abscissas: range(0, mockValues.oneD.length), | ||
ordinates: mockValues.oneD, | ||
errors: mockValues.oneD.map(() => 10), | ||
color: 'blue', | ||
visible: true, | ||
}, | ||
argTypes: { | ||
abscissas: { control: false }, | ||
ordinates: { control: false }, | ||
errors: { control: false }, | ||
color: { control: { type: 'color' } }, | ||
}, | ||
} satisfies Meta<typeof ErrorBars>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default = { | ||
render: (args) => { | ||
const { abscissas, ordinates, errors, ignoreValue } = args; | ||
|
||
const abscissaDomain = useDomain(abscissas); | ||
const ordinateDomain = useDomain( | ||
ordinates, | ||
ScaleType.Log, | ||
errors, | ||
ignoreValue, | ||
); | ||
|
||
assertDefined(abscissaDomain); | ||
assertDefined(ordinateDomain); | ||
|
||
return ( | ||
<VisCanvas | ||
abscissaConfig={{ visDomain: abscissaDomain, showGrid: true }} | ||
ordinateConfig={{ | ||
visDomain: ordinateDomain, | ||
scaleType: ScaleType.Log, | ||
showGrid: true, | ||
}} | ||
> | ||
<DefaultInteractions /> | ||
<ErrorBars {...args} /> | ||
</VisCanvas> | ||
); | ||
}, | ||
} satisfies Story; | ||
|
||
export const Color = { | ||
...Default, | ||
args: { | ||
color: 'red', | ||
}, | ||
} satisfies Story; | ||
|
||
export const IgnoreValue = { | ||
...Default, | ||
args: { | ||
ignoreValue: (val) => val % 5 === 0, | ||
}, | ||
} satisfies Story; |
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,97 @@ | ||
import { | ||
DefaultInteractions, | ||
Glyphs, | ||
GlyphType as GlyphTypeEnum, | ||
useDomain, | ||
VisCanvas, | ||
} from '@h5web/lib'; | ||
import { assertDefined, mockValues, ScaleType } from '@h5web/shared'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { range } from 'lodash'; | ||
|
||
import FillHeight from './decorators/FillHeight'; | ||
|
||
const meta = { | ||
title: 'Building Blocks/Glyphs', | ||
component: Glyphs, | ||
decorators: [FillHeight], | ||
parameters: { | ||
layout: 'fullscreen', | ||
controls: { sort: 'requiredFirst' }, | ||
}, | ||
args: { | ||
abscissas: range(0, mockValues.oneD.length), | ||
ordinates: mockValues.oneD, | ||
glyphType: GlyphTypeEnum.Cross, | ||
color: 'blue', | ||
size: 6, | ||
visible: true, | ||
}, | ||
argTypes: { | ||
abscissas: { control: false }, | ||
ordinates: { control: false }, | ||
glyphType: { | ||
control: { type: 'select' }, | ||
options: Object.keys(GlyphTypeEnum), | ||
}, | ||
color: { control: { type: 'color' } }, | ||
}, | ||
} satisfies Meta<typeof Glyphs>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default = { | ||
render: (args) => { | ||
const { abscissas, ordinates, ignoreValue } = args; | ||
|
||
const abscissaDomain = useDomain(abscissas); | ||
const ordinateDomain = useDomain( | ||
ordinates, | ||
ScaleType.Linear, | ||
undefined, | ||
ignoreValue, | ||
); | ||
|
||
assertDefined(abscissaDomain); | ||
assertDefined(ordinateDomain); | ||
|
||
return ( | ||
<VisCanvas | ||
abscissaConfig={{ visDomain: abscissaDomain, showGrid: true }} | ||
ordinateConfig={{ visDomain: ordinateDomain, showGrid: true }} | ||
> | ||
<DefaultInteractions /> | ||
<Glyphs {...args} /> | ||
</VisCanvas> | ||
); | ||
}, | ||
} satisfies Story; | ||
|
||
export const Color = { | ||
...Default, | ||
args: { | ||
color: 'red', | ||
}, | ||
} satisfies Story; | ||
|
||
export const GlyphType = { | ||
...Default, | ||
args: { | ||
glyphType: GlyphTypeEnum.Square, | ||
}, | ||
} satisfies Story; | ||
|
||
export const Size = { | ||
...Default, | ||
args: { | ||
size: 12, | ||
}, | ||
} satisfies Story; | ||
|
||
export const IgnoreValue = { | ||
...Default, | ||
args: { | ||
ignoreValue: (val) => val % 5 === 0, | ||
}, | ||
} satisfies Story; |
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,71 @@ | ||
import { DefaultInteractions, Line, useDomain, VisCanvas } from '@h5web/lib'; | ||
import { assertDefined, mockValues, ScaleType } from '@h5web/shared'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { range } from 'lodash'; | ||
|
||
import FillHeight from './decorators/FillHeight'; | ||
|
||
const meta = { | ||
title: 'Building Blocks/Line', | ||
component: Line, | ||
decorators: [FillHeight], | ||
parameters: { | ||
layout: 'fullscreen', | ||
controls: { sort: 'requiredFirst' }, | ||
}, | ||
args: { | ||
abscissas: range(0, mockValues.oneD.length), | ||
ordinates: mockValues.oneD, | ||
color: 'blue', | ||
visible: true, | ||
}, | ||
argTypes: { | ||
abscissas: { control: false }, | ||
ordinates: { control: false }, | ||
color: { control: { type: 'color' } }, | ||
}, | ||
} satisfies Meta<typeof Line>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Default = { | ||
render: (args) => { | ||
const { abscissas, ordinates, ignoreValue } = args; | ||
|
||
const abscissaDomain = useDomain(abscissas); | ||
const ordinateDomain = useDomain( | ||
ordinates, | ||
ScaleType.Linear, | ||
undefined, | ||
ignoreValue, | ||
); | ||
|
||
assertDefined(abscissaDomain); | ||
assertDefined(ordinateDomain); | ||
|
||
return ( | ||
<VisCanvas | ||
abscissaConfig={{ visDomain: abscissaDomain, showGrid: true }} | ||
ordinateConfig={{ visDomain: ordinateDomain, showGrid: true }} | ||
> | ||
<DefaultInteractions /> | ||
<Line {...args} /> | ||
</VisCanvas> | ||
); | ||
}, | ||
} satisfies Story; | ||
|
||
export const Color = { | ||
...Default, | ||
args: { | ||
color: 'purple', | ||
}, | ||
} satisfies Story; | ||
|
||
export const IgnoreValue = { | ||
...Default, | ||
args: { | ||
ignoreValue: (val) => val % 5 === 0, | ||
}, | ||
} satisfies Story; |
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.